QQmlIncubationController Class

QQml인큐베이션컨트롤러 인스턴스는 QQml인큐베이터의 진행 상황을 주도합니다. 더 보기...

Header: #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를 사용하면 애플리케이션에서 이 처리가 언제, 얼마나 자주, 얼마나 오래 발생하는지 정확하게 제어할 수 있습니다.

QQmlEngine::setIncubationController() 메서드를 호출하여 QQmlIncubationController 파생 인스턴스를 생성하고 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 가 가리키는 원자 부울이 참인 동안 또는 더 이상 인큐베이션할 개체가 없을 때까지 또는 msecs 가 0이 아닌 경우 msecs 까지 개체를 인큐베이션합니다.

일반적으로 이 메서드는 인큐베이션을 중단하려는 경우 flag 가 가리키는 부울을 false로 설정하는 스레드 또는 UNIX 신호와 함께 사용됩니다.

참고: flag 은 메모리 획득 순서를 사용하여 읽습니다.

int QQmlIncubationController::incubatingObjectCount() const

현재 인큐베이팅 중인 오브젝트 수를 반환합니다.

[virtual protected] void QQmlIncubationController::incubatingObjectCountChanged(int incubatingObjectCount)

인큐베이팅 중인 개체의 수가 변경될 때 호출됩니다. incubatingObjectCount 새로운 인큐베이팅 중인 개체 수입니다.

기본 구현은 아무 작업도 수행하지 않습니다.

© 2025 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.