I'm looking into a question someone had about incubators and I noticed something interesting in its documentation:
The use of QQmlIncubator gives more control over the creation of a QML object, including allowing it to be created asynchronously using application idle time. The following example shows a simple use of QQmlIncubator.
When looking at https://doc.qt.io/qt-6/qcoreapplication.html#processEvents-1, I see:
Use of this function is discouraged. Instead, prefer to move long operations out of the GUI thread into an auxiliary one and to completely avoid nested event loop processing. If event processing is really necessary, consider using QEventLoop instead.
Why are we using this in one of our examples if it's discouraged?
The next paragraph after that example says:
Asynchronous incubators are controlled by a QQmlIncubationController that is set on the QQmlEngine, which lets the engine know when the application is idle and incubating objects should be processed. If an incubation controller is not set on the QQmlEngine, QQmlIncubator creates objects synchronously regardless of the specified IncubationMode.
So my conclusion after reading this, as a user, is that this seems like the "proper" way of doing it (although it should say that a controller is not set by default). Looking at the example on https://doc.qt.io/qt-6/qqmlincubationcontroller.html, then:
For example, this is an example of a incubation controller that will incubate for a maximum of 5 milliseconds out of every 16 milliseconds.
Although the previous example would work, it is not optimal. Real world incubation controllers should try and maximize the amount of idle time they consume - rather than a static amount like 5 milliseconds - while not disturbing the application.
This documentation gives an example, says that it's not optimal, and then provides vague advice about what should actually be done with no concrete solution for how to do it.