Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlIncubationController Class Reference

QQmlIncubationController instances drive the progress of QQmlIncubators. More...

#include <qqmlincubator.h>

+ Inheritance diagram for QQmlIncubationController:
+ Collaboration diagram for QQmlIncubationController:

Public Member Functions

 QQmlIncubationController ()
 Create a new incubation controller.
 
virtual ~QQmlIncubationController ()
 
QQmlEngineengine () const
 Return the QQmlEngine this incubation controller is set on, or 0 if it has not been set on any engine.
 
int incubatingObjectCount () const
 Return the number of objects currently incubating.
 
void incubateFor (int msecs)
 Incubate objects for msecs, or until there are no more objects to incubate.
 
void incubateWhile (std::atomic< bool > *flag, int msecs=0)
 

Protected Member Functions

virtual void incubatingObjectCountChanged (int)
 Called when the number of incubating objects changes.
 

Friends

class QQmlEngine
 
class QQmlEnginePrivate
 
class QQmlIncubatorPrivate
 

Detailed Description

QQmlIncubationController instances drive the progress of QQmlIncubators.

\inmodule QtQml

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 QQmlEngine::setIncubationController() method. Processing is then controlled by calling the QQmlIncubationController::incubateFor() or QQmlIncubationController::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:
PeriodicIncubationController() {
startTimer(16);
}
protected:
void timerEvent(QTimerEvent *) override {
incubateFor(5);
}
};
\inmodule QtCore
Definition qobject.h:103
QQmlIncubationController instances drive the progress of QQmlIncubators.
\inmodule QtCore
Definition qcoreevent.h:366

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.

\l{QQuickWindow}, \l{QQuickView}, and \l{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.

Definition at line 68 of file qqmlincubator.h.

Constructor & Destructor Documentation

◆ QQmlIncubationController()

QQmlIncubationController::QQmlIncubationController ( )

Create a new incubation controller.

Definition at line 194 of file qqmlincubator.cpp.

◆ ~QQmlIncubationController()

QQmlIncubationController::~QQmlIncubationController ( )
virtual

Definition at line 200 of file qqmlincubator.cpp.

References QQmlEnginePrivate::get().

+ Here is the call graph for this function:

Member Function Documentation

◆ engine()

QQmlEngine * QQmlIncubationController::engine ( ) const

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

Definition at line 210 of file qqmlincubator.cpp.

References QQmlEnginePrivate::get().

+ Here is the call graph for this function:

◆ incubateFor()

void QQmlIncubationController::incubateFor ( int msecs)

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

Definition at line 419 of file qqmlincubator.cpp.

References deadline, i, QQmlEnginePrivate::incubatorCount, and QQmlEnginePrivate::incubatorList.

Referenced by QQuickWindowIncubationController::incubate().

+ Here is the caller graph for this function:

◆ incubateWhile()

void QQmlIncubationController::incubateWhile ( std::atomic< bool > * flag,
int msecs = 0 )
Since
5.15

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.

Definition at line 443 of file qqmlincubator.cpp.

References QDeadlineTimer::Forever, i, QQmlEnginePrivate::incubatorCount, and QQmlEnginePrivate::incubatorList.

◆ incubatingObjectCount()

int QQmlIncubationController::incubatingObjectCount ( ) const

Return the number of objects currently incubating.

Definition at line 218 of file qqmlincubator.cpp.

References QQmlEnginePrivate::incubatorCount.

Referenced by QQuickWindowIncubationController::incubate(), and incubatingObjectCountChanged().

+ Here is the caller graph for this function:

◆ incubatingObjectCountChanged()

void QQmlIncubationController::incubatingObjectCountChanged ( int incubatingObjectCount)
protectedvirtual

Called when the number of incubating objects changes.

incubatingObjectCount is the new number of incubating objects.

The default implementation does nothing.

Reimplemented in QQuickWindowIncubationController.

Definition at line 229 of file qqmlincubator.cpp.

References incubatingObjectCount(), and Q_UNUSED.

Referenced by QQmlIncubatorPrivate::clear(), and QQmlEnginePrivate::incubate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QQmlEngine

friend class QQmlEngine
friend

Definition at line 85 of file qqmlincubator.h.

◆ QQmlEnginePrivate

friend class QQmlEnginePrivate
friend

Definition at line 86 of file qqmlincubator.h.

◆ QQmlIncubatorPrivate

friend class QQmlIncubatorPrivate
friend

Definition at line 87 of file qqmlincubator.h.


The documentation for this class was generated from the following files: