Important: Please read the Qt Code of Conduct -

QGLWidget as viewport in QGraphicsView refresh issue when maximize to fullscreen

  • Hi,

    I am developing a Desktop application on Windows 7 x64 using Qt 4.8.2.
    The application has two panes where each contains a QGraphicsView visualizing two different QGraphicsScenes.

    One of the scenes is using QGLWidget as the viewport, where as the other is using a custom DirectX widget as viewport.
    Everything works fine and renders properly, but once I maximize the application to fullscreen mode, the pane that renders using the QGLWidget seems not refreshing properly: it goes on top and covers all other widgets, even when there is nothing loaded in both scenes.

    This happens only on certain machines, so far seems to happen on lower end machines with not so powerful graphics card. And if I remove the line:
    @setViewport(new QGLWidget(QGL::DirectRendering | QGL::DoubleBuffer))@
    then it works fine on all machines, just that the rendering performance is poor.

    Any idea or advice what could be wrong? I suspect it could be due to some resource on the graphics card, but there isn't any warning/error message from Qt when this happens, so can hardly tell really what goes wrong.

    Any help is much appreciated.
    Thanks in advanced.

  • Does anyone have any clue?

  • You may want to try to set the QGraphicsScene's QRect whenever the QGraphicsView::resizeEvent occurs:

    void MyGraphicsView::resizeEvent(QResizeEvent *event)
    if (myScene)
    myScene->setSceneRect(QRectF(QPoint(0, 0), event->size()));

    Can I please ask for how you were able to add a custom Direct X widget to the QGraphicsView viewport? Do you have some sample code that you could share?

  • Hi,

    Thanks for the suggestion and sorry for the late reply.

    The steps to add a DirectX widget as the QGraphicsView viewport is described in this "post":

    Basically, the key is to override the paintEngine() method to return null pointer, and set some of the widget attributes to improve rendering performance.

    Hope this helps.

Log in to reply