0

Qt 6.2.0 Ubuntu 20.04

Content.qml

PathView {
    id: view

    function myFunc(type) {
        console.log(type)
    }
}

Main.qml

ApplicationWindow {
    id: window

    Item {
        id: item

        Content {
          id: content
        }
    }

    Item {
       content.myFunc(1) // <-- Expected token :
    }
}

What is the right syntax to call myFunc()?

1 Answer 1

1

Implementing logic inside a QML item is not allowed, you can call myFunc under a clickable area like following

 MouseArea {
        onClicked: {
            content.myFunc()
        }
    }

you can read more for to get a better understandings from Implementing the Game Logic

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.