You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For qml file with Item element as root of qml scene:
Item {
...
}
it is possible to preview qml file content with QQuickView without window recreation - see slightly modified and simplified qmlscene code:
QQmlEngine engine;
QPointer<QQmlComponent> component = new QQmlComponent(&engine);
QQuickWindow *window = nullptr;
auto qxView = new QQuickView(&engine, nullptr);
...
// Call this slot on file update (for example by QFileSystemWatcher signal)
updatePreview()
{
// Recreate Qml Component
engine.clearComponentCache();
component = new QQmlComponent(&engine);
component->loadUrl(url);
QObject *topLevel = component->create();
// Recreate Quick Window
window = qobject_cast<QQuickWindow *>(topLevel);
if (window) {
engine.setIncubationController(window->incubationController());
} else {
QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel);
if (contentItem) {
window = qobject_cast<QQuickWindow *>(qxView);
qxView->setContent(url, component, contentItem);
}
}
}
For such qml file structure window become nullptr on Quick Window recreation and execution goes to else path of if statement. And there we use single QQuickView instance - qxView, just modifying its content without full reloading and recreation.
However if qml file contains ApplicationWindow as root item of the scene:
ApplicationWindow {
...
}
execution goes by the 1st variant of Quick Window recreation:
https://stackoverflow.com/q/53601421/630169
For qml file with
Item
element as root of qml scene:it is possible to preview
qml
file content withQQuickView
without window recreation - see slightly modified and simplifiedqmlscene
code:For such
qml
file structurewindow
becomenullptr
on Quick Window recreation and execution goes toelse
path ofif
statement. And there we use singleQQuickView
instance -qxView
, just modifying its content without full reloading and recreation.However if
qml
file containsApplicationWindow
as root item of the scene:execution goes by the 1st variant of Quick Window recreation:
and new
QQuickWindow
instance created which takes much more time and force us to destroy and close previous one.Is it possible analogous to
QQuickView
reload scene content forQQuickWindow
without full window recreation? Thanks!The text was updated successfully, but these errors were encountered: