Reputation: 351
Take the following code in QML:
import QtQuick 2.14
import QtQuick.Controls 1.4
TabView {
Tab {
id: firstTab
Component.onCompleted: {
console.log("1")
}
Rectangle {
id: firstTabRectangle
Component.onCompleted: {
console.log("2")
}
}
}
Tab {
id: secondTab
Component.onCompleted: {
console.log("3")
}
Rectangle {
id: secondTabRectangle
Component.onCompleted: {
console.log("4")
}
}
}
}
Now the question is:
What does the console print when the code is executed?
I would have guessed
1 (firstTab)
2 (firstTabRectangle)
3 (secondTab)
But the result is:
3 (secondTab)
1 (firstTab)
2 (firstTabRectangle)
I understand that "4" gets not created because we see the firstTab
"1" with the firstTabRectangle
"2". So secondTabRectangle
"2" is never created until we want to switch to the tab.
Upvotes: 0
Views: 132