QML Canvas synchronization
-
I have a Qt Quick application that can run a series of tests and take multiple screenshots of itself in different states for quality control. Screenshots of the application are taken by calling QQuickWindow::grabWindow() on the root window and the different test pages are loaded with a loader and a list of ql source files / properties.
Normal QML components are rendered synchronously and are visible in the screenshots as soon as the loader is ready. The problem is when one of the pages uses some custom Canvas drawing, in this case the loader become ready before the canvas is actually painted.Is there a way to delay the "object completion" in QML until painted() is called on the canvas so that the component loading is synchronized and I have a consistent behavior with the rest of the QML components. Or, more generally, is there a way to delay a QML "object completion" until a certain signal is triggered?
I could trigger a signal on the object handling the screenshot logic from all the Canvas objects to synchronize it but it does not seem like a nice solution.
I tried to change the render strategy of the canvas object but it doesn't really change anything, at least not on my platform (linux with software renderer).TY, Federico
-
Would delaying the screenshot for one render loop be enough?
-
QTimer::singleShot(0, this, [=] { doTheScreenshot(); });
should do it.