[英]Reload QQuickView into the same window container
I want to write plugins to my program as qml displaying inside dock widget 我想将Qml显示在码头小部件内以将插件写入程序
I load plugin this way: 我以这种方式加载插件:
if (!qview)
qview = new QQuickView();
qview->engine()->clearComponentCache();
qview->setSource(QUrl(path));
QQuickItem *item_main = qview->rootObject();
QWindow* main_page = item_main->window();
auto container = QWidget::createWindowContainer( main_page, ui- >dockWidgetContents );
container->show();
It works ok, but reloading plugin is quite slow and causes flickering. 它可以正常工作,但是重新加载插件的速度很慢,并且会导致闪烁。 I think it is because createWindowContainer creates native window each time.
我认为这是因为createWindowContainer每次都会创建本机窗口。 Can I speed up reloading by forcing QQuickView use the same window container after reload or somehow avoid window flickering?
是否可以通过在重新加载后强制QQuickView使用相同的窗口容器来加快重新加载速度,或者以某种方式避免窗口闪烁?
The solution happens to be quite simple: 解决方案恰好很简单:
if (!qview) {
QWindow *wnd = new QWindow();
QWidget::createWindowContainer(wnd, ui->dockWidgetContents )->show();
qview = new QQuickView(wnd);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.