I have a Qml component consisting of sub-components. After everything has been loaded (rendered) I want to perform some action.
Is there a way to find out when all components are loaded? Just using the Component.onCompleted
event on the root element does not suffice because the children are not guaranteed to be loaded.
Regards,
You should be able to use the afterSynchronizing()
signal of QQuickWindow
to achieve this:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
ApplicationWindow {
visible: true
width: 1280
height: 700
property bool initialised: false
onAfterSynchronizing: {
if (!initialised) {
print("initialising...");
// stuff...
initialised = true;
}
}
}
Pros:
Cons:
QQuickWindow
derivatives.An alternative is to use a Loader
; specifically its loaded()
signal:
Loader {
source: "MyComponent.qml"
onLoaded: {
// stuff...
}
}
Pros:
Window
; can use it at any level in your scene's "hierarchy".Cons:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With