Qt Embedded: displaying on two screens using QGraphicsView and QGraphicsWidget

  • I am using Embedded QT 4.8..7. Widgets are based on QGraphicsView and QGraphicsWidget. Need to control two displays.

    So far I was able to find suggestions how to control two displays using QDesktopWidget, which is QWidget. I assume there must be a way to control two screens, using two frame buffers, via QGraphicsWidget.

    Can somebody please give me a reference with examples how to paint on two screens using QGraphicsView and QGraphicsWidget, and two frame buffers?
    Can all the widgets still be added to the same QGraphicsScene?

    Is there a need to offset widget rectangles for the second display, before adding them to the scene?

    How and when to move between the screens? Using QRect geometry = pDesktop->availableScreenGeometry(screen_number); pQGraphicsView->move(geometry.topLeft())?

    Dusan Mudric.

  • Lifetime Qt Champion


    Do you mean you want to have a single QGraphicsView spanning both screens ?

  • Yes, something like this:

            MainWindow Display0;
            MainWindow Display1;
            QGraphicsScene* pScene = new QGraphicsScene();
            pScene->setSceneRect(0, 0, screen1_X+screen2_X, max(screen1_Y, screen2_Y);
            QGraphicsView* pView =  new QGraphicsView(pScene)
            QDesktopWidget *pDesktop = QApplication::desktop();
            QRect geometry = pDesktop->availableScreenGeometry(1);
            // Move screen1 Display to the second screen. This should allow to place widgets from the scene the second screen. For the widgets on the second screen, do widgets rectangles need to be shifted by screen1_X?
            pView->move(geometry.topLeft()); // luckily QGraphicsView is QWidget and call move(). Does this move from one to another screen has to happen every time screen0 or screen1 widgets are painted?

  • Lifetime Qt Champion

    Are you using the QWS system ?

  • I am not using anything yet. Still looking for the options. What is QWS supposed to do and how? Is it related to https://doc.qt.io/archives/qtextended4.4/tut-dualdisplay.html?

  • Lifetime Qt Champion

    Since you're using Qt for Embedded, you should read the corresponding documentation.

    By the way, are you tied to that version ? Qt 4 has reached end of life a long time ago therefore you should consider going with Qt 5.

  • I am not using QWS Client-Server architecture. Only MainWindow, QGraphicsScene and QGraphicsView. I want to avoid any major redesign to support two screens. Qt5 is not an option. Have to stay with 4.8.

    http://doc.qt.io/archives/qt-4.8/qt-embedded-running.html ("Using the Multi screen driver, on the other hand, applications can easiliy be moved between the various screens."). Where are the examples of this easy implementation?

    Is there somebody in QT who knows how to make it working with the pseudo code above?


  • Lifetime Qt Champion

    Then what are you using to display your application ? An X.org server ?

  • QGraphicsWidget calls update(), QT calls back QGraphicsWidget::paint() with the pointer to the painter. This painter is used to draw images pPainter->drawPixmap();

  • Lifetime Qt Champion

    I mean what backend are you using ? If not QWS, do you have an Xorg server running on your device ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.