I've found this, but it is only about QWidget based project. What about ApplicationWindow
components in QML?
我发现了这个,但它只是关于基于QWidget的项目。 QML中的ApplicationWindow组件怎么样?
1 个解决方案
#1
Finally I've connected to frameSwapped
signal of the main top-level QQuickWindow
of my application. It is called right after each repainting is done. So, after first repainting, my slot would be called, and I will start to really load the data (what is rather slow). Inside this slot I'm destroying this connection, so I don't slow down the application.
最后我连接到我的应用程序的主要*QQuickWindow的frameSwapped信号。每次重新粉刷完成后立即调用。因此,在第一次重新绘制之后,我的插槽将被调用,我将开始真正加载数据(这是相当慢的)。在这个插槽里面我正在破坏这个连接,所以我不会减慢应用程序的速度。
//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);
}
Hope it will be helpful for someone.
希望它对某人有所帮助。
#1
Finally I've connected to frameSwapped
signal of the main top-level QQuickWindow
of my application. It is called right after each repainting is done. So, after first repainting, my slot would be called, and I will start to really load the data (what is rather slow). Inside this slot I'm destroying this connection, so I don't slow down the application.
最后我连接到我的应用程序的主要*QQuickWindow的frameSwapped信号。每次重新粉刷完成后立即调用。因此,在第一次重新绘制之后,我的插槽将被调用,我将开始真正加载数据(这是相当慢的)。在这个插槽里面我正在破坏这个连接,所以我不会减慢应用程序的速度。
//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);
}
Hope it will be helpful for someone.
希望它对某人有所帮助。