I have a requirement for my project to display two QML Windows each on one of the screen (one sender, one receiver). Both of the .qml requires me to in
That can be done easier, for example:
main.qml
import QtQuick 2.3
import QtQuick.Window 2.2
Item {
Window {
objectName: "wnd1"
visible: true
}
Window {
objectName: "wnd2"
visible: true
}
}
And so you can access these windows from C++ code:
main.cpp
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QQuickWindow *wnd1 = engine.rootObjects()[0]->findChild("wnd1");
if(wnd1)
wnd1->setTitle("Server");
QQuickWindow *wnd2 = engine.rootObjects()[0]->findChild("wnd2");
if(wnd2)
wnd2->setTitle("Client");
To catch a closing event you should use QQuickWindow::closing event