Using Qt.callLater ?
-
wrote on 7 Apr 2021, 07:27 last edited by
Is it safe to use Qt.callLater? Does it have any disadvantages?
Eg: If i have one QML which loads another QML using loader. Can I provide the source of the loader using a Qt.callLater Function? -
wrote on 7 Apr 2021, 14:21 last edited by
https://doc.qt.io/qt-5/qml-qtqml-qt.html#callLater-method
What is your criteria for "safe"?
-
wrote on 8 Apr 2021, 04:01 last edited by
Hi @fcarney,
So in My application there are multiple UI updates that happen, so when i want to open a page(Like a Menu), i would like to open the Menu, Just by loading the Title Bar first and the contents of the Menu just after, without any visible Glitch.
So i would load the TitleBar and on the component.oncompleted of the TitleBar, i would perform a callLater for the contents of the same.
So my question is : When i write callLater to load the contents of the page under the Title bar, will it occur immediately after the titlebar or will the operation be puushed to the end of the Events queue, due to which i could possibly see a visible delay? Currently in my application i do not see any delay, but in case of long runs/ heavy operations , is it possible that there might be a delay?
-
wrote on 8 Apr 2021, 14:09 last edited by
You will have to test this by loading your system. The next event loop iteration might be milliseconds away. You will have to read up on the event loop as to how long that is and if that is acceptable.
-
wrote on 8 Apr 2021, 14:12 last edited by
I wonder why you are using Component.onCompleted to load data? I would think a demand driven model based upon QAbstractListModel/ItemModel might be better.
-
wrote on 8 Apr 2021, 16:56 last edited by
Hi @fcarney ,
Yes I will check the same . Thank you for the Input.No Actually I am loading another qml on the completion of the load of a titlebar page.
So My QMl looks like :
Menu.qml{
Rectangle{
id:titleRect
.
.
Text{
.
.
.
}
}
Loader{
id:loadId
anchors.top : titleRect.bottom}
function setSource()
{
loadId.source = "Menu_Page1.qml"
}
Component.onCompleted:{
Qt.callLater(setSource)
}
}@fcarney : Thanks for your inputs. :)
4/6