Reputation: 307
This question is regarding QML, QtQuick 1.1, Qt 4.8.6
I have seen source code of an embedded application, in which all the screens are loaded at start. For Example,
//Main.qml
Rectangle{ //Base Container
width:640
height:480
MainScreen{ id: main_screen} //Individual screen files are given here
SettingScreen1 { id:screen1}
SettingScreen2 { id:screen2}
HelpScreen1 {id: help_screen1}
...
...
...
}
and in the respective screen document, when a mouse area is clicked the Value of Z
of the individual document is changed to make it appear front
//MainScreen.qml
Rectangle{
width: 640
height:480
z:1
//some buttons
//Mousearea for next button
onClicked: {screen1.z = 10}
//Mousearea for back button
onClicked: {screen1.z = 0}
}
My question is,
1. As from main.qml all the children are created at once and only their visibility of stack order is changed. Is this a good method?
2. When so many children are loaded at beginning what happens if I have like 200 screens. What is the effect in CPU load at start and while operation.
Is there any other method for screen transitions?
Other than component loader. I don`t want to use that feature
How this code is converted and showed in display as an object?
I will be very happy is least you can give hints in comments.
Thanks!!
Upvotes: 1
Views: 1122
Reputation: 13691
To your questions:
1): Bad Idea. Using the z-index needs the engine to determine that the lower items are hidden completely. You should help the enigne if you are sure about this (which would be the case here) by setting the visibility
to false. Then however, you would not need to use the z-index at all. Don't use the z-index. Don't!
However this won't solve that you might have 200 possibly complex views in your memory.
The Loader
you mentioned is already a better start.
You can use it in combination with the visibility to preload pages that are likely to be shown soon, and unload them once you are sure they are not shown anytime soon (within the next one or two clicks)
2): The effect is: Long time of unresponsivenes until everything is loaded. The documentation sais: Show a splash-screen if you want to do something like this. In order to show the splash-screen, show it, then use a Loader
to load all the other stuff... But in general: Don't do it, if not absolutly necessary. Load dynamically. Never use the z-index to hide screens completely. Load only what needs to be loaded... I feel repetitive...
Upvotes: 3