Qt World Summit: Register Today!

Using (signal) to determine a specific page

  • 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.


    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


    // If i was on another page and then entered page1 i want to change the value of (bool change)
            page1.change=true  // should I write like this

    I tried to do like this but did not work with me (did not show (true) in consol)

  • Qt Champions 2017

    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.

Log in to reply