3

I am trying to create Qt application rendering to two displays. QNX is already configured, for 2 displays. We created two windows, but how do we tell Qt to render a window to the 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();

In output I can see 2 windows displaying the QMLs. But they are being rendered on same display. How do I attach the windows to different screens ?

1 Answers1

2

The QtQuick2ApplicationViewer inherits from QQuickView, and thus from QWindow. You can thus set the screen for each of the viewers:

viewer1.setScreen(app.screens().first());
viewer2.setScreen(app.screens().last());
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • I tried this and Views were attached to QScreens. But on QNX side both screens are still being displayed on same display. Is there any way to link these QScreens to QNX Screens ? – user3320968 Feb 18 '14 at 16:44
  • @user3320968 Check this: `Q_ASSERT(app.screens().count() == 2);` If it is so, then you must do some reading on Qt support for QNX. – Kuba hasn't forgotten Monica Feb 18 '14 at 17:52