0
我發現this,但它只是關於基於QWidget的項目。那麼QML中的ApplicationWindow
組件呢?是否有任何QML窗口UI完全構建的信號?
我發現this,但它只是關於基於QWidget的項目。那麼QML中的ApplicationWindow
組件呢?是否有任何QML窗口UI完全構建的信號?
最後我連接到frameSwapped
信號的主要頂級QQuickWindow
我的申請。它在每次重新繪製完成後立即被調用。所以,第一次重新繪製後,我的槽將被調用,並且我將開始真正加載數據(速度很慢)。在這個插槽裏,我銷燬了這個連接,所以我不會減慢應用程序的速度。
//main.cpp
QQuickWindow* mainWindow =
qobject_cast<QQuickWindow*>(engine.rootObjects().first());
QMetaObject::Connection loadingFinished =
QObject::connect(mainWindow, SIGNAL(frameSwapped()),
&controller, SLOT(construct()));
controller.setConnection(loadingFinished);
//Controller.cpp
void Controller::construct() // this is slot
{
// some really long operation
disconnect(*m_loadingFinished);
}
希望對某人有幫助。
你試過'Component.onCompleted'嗎? – ixSci
@ixSci是的,用於ApplicationWindow組件及其子組件。但在整個UI加載之前調用它。 – VALOD9
你有在你的用戶界面動態加載元素? – cmannett85