Qt / Qml for two different displays on the QNX platform

I am trying to create a Qt application rendering for two displays. QNX is already configured for two displays. We created two windows, but how can we tell Qt to display the window on a second display?

Here is my code snippet

QGuiApplication app(argc, argv);

QtQuick2ApplicationViewer viewer1;
QtQuick2ApplicationViewer viewer2;

init();

viewer1.setMainQmlFile(QStringLiteral("qml/VisionBuck/main.qml"));
viewer1.showExpanded();

viewer2.setMainQmlFile(QStringLiteral("qml/VisionBuck/display2.qml"));
viewer2.showExpanded();

At the output, I can see 2 windows displaying QML. But they are displayed on one display. How to attach windows to different screens?

+3
source share
1 answer

QtQuick2ApplicationViewerinherits from QQuickViewand therefore from QWindow. Thus, you can adjust the screen for each of the viewers:

viewer1.setScreen(app.screens().first());
viewer2.setScreen(app.screens().last());
+2
source

All Articles