QQmlIncubationController Class
QQmlIncubationController 인스턴스는 QQmlIncubators의 진행 상황을 주도합니다. 더 보기...
| 헤더: | #include <QQmlIncubationController> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
| qmake: | QT += qml |
공개 함수
| QQmlIncubationController() | |
| QQmlEngine * | engine() const |
| void | incubateFor(int msecs) |
| void | incubateWhile(std::atomic<bool> *flag, int msecs = 0) |
| int | incubatingObjectCount() const |
보호된 함수
| virtual void | incubatingObjectCountChanged(int incubatingObjectCount) |
상세 설명
애플리케이션에서 비동기적으로 동작하고 끊김이나 멈춤 현상이 발생하지 않도록 하려면, QQmlIncubators 객체를 생성하는 과정은 애플리케이션의 유휴 시간 동안에만 수행되어야 합니다. QQmlIncubationController를 사용하면 애플리케이션이 이 처리가 언제, 얼마나 자주, 얼마나 오랫동안 수행될지 정확히 제어할 수 있습니다.
QQmlIncubationController에서 파생된 인스턴스를 생성하고, ` QQmlEngine::setIncubationController()` 메서드를 호출하여 ` QQmlEngine `에 설정해야 합니다. 그런 다음 애플리케이션의 요구 사항에 따라 ` QQmlIncubationController::incubateFor()` 또는 ` QQmlIncubationController::incubateWhile()` 메서드를 호출하여 처리를 제어합니다.
예를 들어, 다음은 16밀리초마다 최대 5밀리초 동안 인큐베이션을 수행하는 인큐베이션 컨트롤러의 예시입니다.
class PeriodicIncubationController : public QObject,
public QQmlIncubationController
{
public:
PeriodicIncubationController() {
startTimer(16);
}
protected:
void timerEvent(QTimerEvent *) override {
incubateFor(5);
}
};이 예제는 작동하지만, 지나치게 단순화되어 있습니다. 실제 인큐베이션 컨트롤러는 애플리케이션에 지장을 주지 않으면서 소비하는 유휴 시간을 최대한 늘리려고 합니다. 위와 같이 5밀리초라는 고정된 값을 사용하면, 어떤 프레임에서는 유휴 시간을 충분히 활용하지 못하고, 다른 프레임에서는 애플리케이션에 지장을 줄 수 있습니다.
QQuickWindow, QQuickView 및 QQuickWidget 은 모두 더 지능적인 알고리즘을 사용하여 여러 프레임에 걸쳐 인큐베이션을 분산시키는 인큐베이션 컨트롤러를 미리 생성해 둡니다. 직접 인큐베이션 컨트롤러를 작성해야 할 경우는 거의 없습니다.
멤버 함수 문서
QQmlIncubationController::QQmlIncubationController()
새로운 인큐베이션 컨트롤러를 생성합니다.
QQmlEngine *QQmlIncubationController::engine() const
이 인큐베이션 컨트롤러가 설정된 엔진( QQmlEngine )을 반환하거나, 어떤 엔진에도 설정되어 있지 않은 경우 0을 반환합니다.
void QQmlIncubationController::incubateFor(int msecs)
msecs 에 대한 객체를 인큐베이션하거나, 인큐베이션할 객체가 더 이상 없을 때까지 진행합니다.
void QQmlIncubationController::incubateWhile(std::atomic<bool> *flag, int msecs = 0)
flag 가 가리키는 원자형 bool 값이 true인 동안, 또는 인큐베이트할 객체가 더 이상 없을 때까지, 혹은 msecs 가 0이 아닐 경우 msecs 까지 객체를 인큐베이트합니다.
일반적으로 이 메서드는 인큐베이션 중단을 원할 때 flag 가 가리키는 bool 값을 false로 설정하는 스레드나 UNIX 신호와 함께 사용됩니다.
참고: flag 는 acquire 메모리 순서를 사용하여 읽힙니다.
int QQmlIncubationController::incubatingObjectCount() const
현재 인큐베이션 중인 객체의 개수를 반환합니다.
[virtual protected] void QQmlIncubationController::incubatingObjectCountChanged(int incubatingObjectCount)
인큐베이션 중인 객체의 수가 변경될 때 호출됩니다. ` incubatingObjectCount `는 인큐베이션 중인 객체의 새로운 수입니다.
기본 구현은 아무 작업도 수행하지 않습니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.