QML Loader: signal when Item is completed



  • I am changing one page in a SwipeView depending on buttons pressed on a different page of that SwipeView

    SwipeView {
       Item { id: firstPage
          MyButton { onClicked: secondPage.setSource("PageA.qml") }
          MyButton { onClicked: secondPage.setSource("PageB.qml") } 
       }
    
        Loader { id: secondPage }
    }
    

    I need to access the objects on the secondPage from the C++ side. Therefore, I connect to the loaded signal

    QQuickItem *p_loaderPage = object->findChild<QQuickItem *>("loaderPage");
    Q_CHECK_PTR(p_loaderPage);
    connect(p_loaderPage, SIGNAL(loaded()), this, SLOT(findViews()));
    

    When I first load a page (say pageA) everything seems to be working fine. But if I load a new page on top of that (either pageB or pageA a second time), I still get the data from the old page in findViews(). It seems that the signal is triggered too early. I'd appreciate any help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.