qt - QML BusyIndicator while loading a heavy qml file -


i've been trying run busyindicator (http://doc.qt.io/qt-5/qml-qtquick-controls-busyindicator.html) while loading qml file (http://doc.qt.io/qt-5/qml-qtquick-loader.html), busyindicator doesn't appear.

what trying is: 1- user emits "handlerloader(name)", "name" url of next qml page. 2- in "onhandlerloader" run busyindicator. 3- then, change loader source.

the problem no matter time spent between steps 2 , 3, busyindicator not appear.

moreover, when comment step 3, busyindicator appears correctly.

what doing wrong?

thanks!!

this code:

rectangle {      visible: true     width: 800     height: 480     signal handlerloader (string name)     loader {         id: pageloader;         source: "init.qml";     }      busyindicator {         id: busyindicator_inicio         width: 100         height: 100         anchors.centerin: parent         running: false     }      connections {         target: pageloader.item         onhandlerloader: {              busyindicator_inicio.running = true              pageloader.source = name;         }     } } 

the reason is, heavy-loading loader blocking thread. set asynchronous mode, allow rest of program run. further, i'd recommend prefer declarative bindings imperative assignments in handlers. see example:

main.qml:

import qtquick 2.4 import qtquick.window 2.2 import qtquick.controls 2.0  window {     width: 1000     height: 800     visible: true      button {         text: 'load'         onclicked: {             loader.source = "testobj.qml"         }     }      loader {         anchors.fill: parent         id: loader         active: true         asynchronous: true         visible: status == loader.ready     }      busyindicator {         id: ind         anchors.fill: parent         running: loader.status == loader.loading     } } 

testobj.qml:

import qtquick 2.0  item {     grid {         anchors.fill: parent         columns: width         rows: height         repeater {             model: 100             rectangle {                 width: { (var = 0; < 10000; i++) console.log(i); return 1 }                 height: 1                 color: 'green'             }         }     } } 

since asynchronous loader might display incomplete files time, set visible when status changes ready.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -