Using (signal) to determine a specific page
Unsolved
QML and Qt Quick
-
How can I use (signal) to know that i am on a specific page on my application. For example if I have 3 pages, and i want to say that i am on this specific page when i am on it by giving a signal.
a sample code to describe what i want.
Page1.qml
Rectangle { id: page1 width: 320 height: 240 clip: true signal thisPageEnter // I want to use this signal to say that i am on page 1 property bool change: false // a variable i want to change when i enter this page 1 }
Page2.qml
// If i was on another page and then entered page1 i want to change the value of (bool change) Page1{ id:abc onThisPageEnter:{ page1.change=true // should I write like this conslo.log(change) } }
I tried to do like this but did not work with me (did not show (true) in consol)
-
How are you creating the page1, page2 and page3 objects ? Where are you creating ? How do you navigate between the pages ? When are you emitting the signal ?
If you are using the Loader to load the Page1, Page2 or Page3 every time, component.onCompleted signal is the best bet for you.
If you are creating the object at one shot and just navigating, then your navigation signal should act like a trigger for you.