class QQmlIncubationController#

QQmlIncubationController instances drive the progress of QQmlIncubators. More

Synopsis#

Methods#

Virtual methods#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

In order to behave asynchronously and not introduce stutters or freezes in an application, the process of creating objects a QQmlIncubators must be driven only during the application’s idle time. QQmlIncubationController allows the application to control exactly when, how often and for how long this processing occurs.

A QQmlIncubationController derived instance should be created and set on a QQmlEngine by calling the setIncubationController() method. Processing is then controlled by calling the incubateFor() or incubateWhile() methods as dictated by the application’s requirements.

For example, this is an example of a incubation controller that will incubate for a maximum of 5 milliseconds out of every 16 milliseconds.

class PeriodicIncubationController : public QObject,
                                     public QQmlIncubationController
{
public:
    PeriodicIncubationController() {
        startTimer(16);
    }

protected:
    void timerEvent(QTimerEvent *) override {
        incubateFor(5);
    }
};

Although the example works, it is heavily simplified. Real world incubation controllers try and maximize the amount of idle time they consume while not disturbing the application. Using a static amount of 5 milliseconds like above may both leave idle time on the table in some frames and disturb the application in others.

QQuickWindow, QQuickView, and QQuickWidget all pre-create an incubation controller that spaces out incubation over multiple frames using a more intelligent algorithm. You rarely have to write your own.

__init__()#

Create a new incubation controller.

engine()#
Return type:

QQmlEngine

Return the QQmlEngine this incubation controller is set on, or 0 if it has not been set on any engine.

incubateFor(msecs)#
Parameters:

msecs – int

Incubate objects for msecs, or until there are no more objects to incubate.

incubateWhile(flag[, msecs=0])#
Parameters:
  • flagatomic

  • msecs – int

Incubate objects while the atomic bool pointed to by flag is true, or until there are no more objects to incubate, or up to msecs if msecs is not zero.

Generally this method is used in conjunction with a thread or a UNIX signal that sets the bool pointed to by flag to false when it wants incubation to be interrupted.

Note

flag is read using acquire memory ordering.

incubatingObjectCount()#
Return type:

int

Return the number of objects currently incubating.

incubatingObjectCountChanged(arg__1)#
Parameters:

arg__1 – int

Called when the number of incubating objects changes. incubatingObjectCount is the new number of incubating objects.

The default implementation does nothing.