How to use an id an of a file.qml in the main file.qml?
-
Hello to all,
In my project I have two files : file1.qml and main.qml
In the file1.qml I defined dynamic functions to draw a curve and in the timer(with id:myTimer) I call these functions.Now in my main, I want to call the id of the timer (myTimer) which is in the file1.qml to be able to use it when I click on a button.
What I don't know is how to call this id: myTimer in my main.
I tried aliases like :
Property alias toStop: myTimerBut I get the error" id myTimer not find".
-
Hello to all,
In my project I have two files : file1.qml and main.qml
In the file1.qml I defined dynamic functions to draw a curve and in the timer(with id:myTimer) I call these functions.Now in my main, I want to call the id of the timer (myTimer) which is in the file1.qml to be able to use it when I click on a button.
What I don't know is how to call this id: myTimer in my main.
I tried aliases like :
Property alias toStop: myTimerBut I get the error" id myTimer not find".
@Ngouda said in How to use an id an of a file.qml in the main file.qml?:
Now in my main, I want to call the id of the timer (myTimer) which is in the file1.qml to be able to use it when I click on a button.
What I don't know is how to call this id: myTimer in my main.
I tried aliases like :
Property alias toStop: myTimer
But I get the error" id myTimer not find".You cannot access
idof any external QML file. QML engine does not allow it. What you can do is create an alias property in your file1.qml and then read that in main./// File1.qml (QML components HAVE TO start with upper case letter!) Item { property alias timer: myTimer /// ... /// main.qml File1 { id: myFile } Button { onClicked: myFile.timer.start()