Problem getting Screen.desktopAvailableHeight when Component.onCompleted
-
I have an common listview control just like the 'LauncherList' in Qt examples, and adding items at Component.onCompleted. Every item's height is depending on the app window height which is same with Screen.desktopAvailableHeight.
But in Qt Doc, it said 'Screen type is not valid at Component.onCompleted, because the Item or Window has not been displayed on a screen by this time'.
I have tested on some android devices. Some device can get Screen.desktopAvailableHeight value at Component.onCompleted, but Nexus 7 can not.
Is there any way I can add items just like in Component.onCompleted ?
Sorry for my poor English.
Thanks! -
Hi,
If you are using a Loader to load a component you can bind the "active":http://qt-project.org/doc/qt-5/qml-qtquick-loader.html#active-prop property to Component.Ready state thus ensuring it will load when main component is ready.
Or you can just use a Timer element with a small delay to call some function which will further create the remaining objects. -
I see.
Thank you. :)