Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Signal that a component is completed AND visible?
is there a way to figure out that a qml component is loaded and visible? Component.onCompleted() seems to be signaled before the component is visible on the screen.
Gennon last edited by
I usually do not need another signal than Component.onCompleted(), so what is your scenario? Why do you need to know if it is visible as well?
thanks for the reply. Starting from the main page, if a user presses a certain Button, I'm loading a totally new screen using the Loader component. For this particular screen I need to initialize and read in some data from external hardware, which might take a few seconds. I thought of starting this process upon Component.onCompleted() and then displaying a progressbar and also fill in the data while I'm retrieving it from the external sensors, so that the user can see whats going on and on his/her discretion also cancel the whole process.
Starting this activity from within Component.onCompleted() works fine except that I don't see the new screen, progress bar etc. until everything is done (I do call QApplication::processEvents() frequently, while I'm waiting for the hardware init to complete).
It's not a big problem, there are ways to work around this. Just thought that there might be some signal or method to know once all QML components are ready and visible.
Gennon last edited by
First off the Loader has a "progress":http://qt-project.org/doc/qt-5/qml-qtquick-loader.html#progress-prop and a "status":http://qt-project.org/doc/qt-5/qml-qtquick-loader.html#status-prop property that you could use.
However if you have some sensors and C++ objects then you could always let those objects emit some signals while they process the data. And you could use a "Connections":http://qt-project.org/doc/qt-5/qml-qtqml-connections.html element in your QML to catch those.
Does this help in any way?
not really. Just tried the signals and status info of the Loader component, but it seems that those signals are also emitted just before the new screen visible. I think I'll do my UI a bit differently to avoid this kind of issues.
Nevertheless: THANKS for helping!