@emppu
How to prevent that a user opens the same window twice? Do I need a flag variable in C++ code or is it easily done in QML? This seems a common workflow (preference window, open/save dialog, etc). I don't want to disable the main window while About window is open.
You can do it right itself in QML. Declare component as global property and then check for null before creating that component.
property Component component
...
MenuItem {
...
onTriggered: {
if(!component) {
component = Qt.createComponent("About.qml");
var about = component.createObject(main);
about.show();
}
}
}
In my case main window didn't disable. Did you set any particular Qt::WindowFlags flag ?
If I keep an instance of About window as an attribute of main ApplicationWindow, does it occupy the memory since the main window is loaded? If I have many different windows, this is really inefficient. What's the simplest solution?
Anything instantiated will occupy memory. To delay that process you use the technique you mentioned or you can use Loader to load them dynamically.