hi all:
I use Qt5.3 with QtQuick2.0.
First, I use the Loader to load “screen1.qml”. screen1.qml just has a Rectangle element with objectName = “screen1”.
Then, when the user click the Rectangle on the screen1.qml, I change the Loader.source to “screen2.qml”.
screen2.qml just has a Rectangle element with objectName = “screen2”, too.
On the Loader::onLoaded (), I connect a single to a c++ slot.
In the c++ slot, I use QObject::findChild() to see if child object “screen1” and “screen2” could be found.
When the Loader.source sets to “screen2.qml”, and the Loader::onLoaded () is called, the slot still shows that screen1 and screen2 could be found!!
Why the screen1 could be found? I has already changed the Loader.source to “screen2.qml”!
In the QT document, it writes “If the source or sourceComponent changes, any previously instantiated items are destroyed.”
But if I sets the “asynchronous” property of the Loader to “true”, everything is OK!! (the slot just shows that screen2 could be found, no screen1 )
I am confused….
(sorry for my poor english)
↧