Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple Qopenglwidget rendering issue
Forum Updated to NodeBB v4.3 + New Features

Multiple Qopenglwidget rendering issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 297 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    ManjunathXI
    wrote on last edited by
    #1

    We are currently in the process of porting our project from Qt 5.15 to Qt 6.5.6. In Qt 5.15, we were successfully using QGLWidget in conjunction with QGraphicsView. However, after the upgrade to Qt 6, we have replaced QGLWidget with QOpenGLWidget due to the deprecation of QGLWidget. Unfortunately, this change has caused an issue when setting the viewport for QGraphicsView using setViewport().

    The issue we are facing is that when we call setViewport() with QOpenGLWidget, it results in a white screen, and we are unable to see the 3D image in QVTKOPENGLNATIVEWIDGET. However, if we comment out the setViewport() line, the rest of the functionality works fine, but this is not an option as setViewport() is required for further processing in our application.

    Additionally, we have tried enabling Qt::AA_ShareOpenGLContexts and setting a shared OpenGL context, but neither approach resolved the issue. Here is the relevant part of the code:

    QGraphicsScene* scene = new QGraphicsScene();
    graphicsView->setScene(scene);

    QSurfaceFormat fmt;
    fmt.setSwapInterval(0); // Turn off vSync.
    fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);

    QOpenGLWidget* openGLWidget = new QOpenGLWidget();
    openGLWidget->setFormat(fmt);

    // Commenting setViewport works fine, but setViewport causes a white screen
    // graphicsView->setViewport(openGLWidget);
    graphicsView->resize(800, 600);

    // Graphics widget contains OpenGLWidget which loads a 3D image, graphics widget has QVTKOPENGLNATIVEWIDGET
    scene->addItem(view->graphicsWidget());

    graphicsView->setFrameStyle(QFrame::NoFrame);
    graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    graphicsView->setOptimizationFlag(QGraphicsView::DontSavePainterState);

    graphicsView->show();

    Could you please review this issue and provide guidance on how to resolve it? Any suggestions on getting the QOpenGLWidget to work properly with setViewport() would be greatly appreciated.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You should try to create a minimal, compilable example and create a bug report then.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved