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. QGraphicsView overlay on top of QOpenGLWidget?

QGraphicsView overlay on top of QOpenGLWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
openglqgraphicsviewqopenglwidget
2 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jdlyga
    wrote on last edited by
    #1

    I have an idea that sounds possible on paper but I've been having trouble implementing.

    I have a QOpenGLWidget that is used to view a large high resolution image. (It's using OpenGL for efficiency since there's a lot of cuts made to the image using clipping, etc). I'm trying to overlay a QGraphicsView+QGraphicsScene on top of the QOpenGLWidget to draw shapes and lines on top of the image, and interact with those shapes and lines.

    I've been having a couple problems with this. First, I can't figure out a way to overlay the QGraphicsView on top of the QOpenGLWidget. I've tried a number of suggestions, including setting the two widgets to the same cell in a grid layout.

    QGridLayout * layout = new QGridLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(m_GraphicsView);
    layout->addWidget(m_ImageGL);
    m_Owner->setLayout(layout);
    

    However, this isn't working. I'm only seeing one of the widgets. I figure this might be a transparency issue, so I tried setting some transparency flags.

    m_GraphicsView->viewport()->setAttribute(Qt::WA_TranslucentBackground);
    m_GraphicsView->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    m_GraphicsView->viewport()->setAttribute(Qt::WA_NoBackground);
    m_GraphicsView->viewport()->setWindowFlags(Qt::FramelessWindowHint);
    m_GraphicsView->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    m_GraphicsView->viewport()->setStyleSheet("background: transparent");
    
    m_GraphicsView->setAttribute(Qt::WA_TranslucentBackground);
    m_GraphicsView->setAttribute(Qt::WA_NoSystemBackground);
    m_GraphicsView->setAttribute(Qt::WA_NoBackground);
    m_GraphicsView->setWindowFlags(Qt::FramelessWindowHint);
    m_GraphicsView->setAttribute(Qt::WA_NoSystemBackground);
    m_GraphicsView->setStyleSheet("background: transparent");
    
    
    m_ImageGL->viewport()->setAttribute(Qt::WA_TranslucentBackground);
    m_ImageGL->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    m_ImageGL->viewport()->setAttribute(Qt::WA_NoBackground);
    m_ImageGL->viewport()->setWindowFlags(Qt::FramelessWindowHint);
    m_ImageGL->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    m_ImageGL->viewport()->setStyleSheet("background: transparent");
    
    m_ImageGL->setAttribute(Qt::WA_TranslucentBackground);
    m_ImageGL->setAttribute(Qt::WA_NoSystemBackground);
    m_ImageGL->setAttribute(Qt::WA_NoBackground);
    m_ImageGL->setWindowFlags(Qt::FramelessWindowHint);
    m_ImageGL->setAttribute(Qt::WA_NoSystemBackground);
    m_ImageGL->setStyleSheet("background: transparent");
    

    I might have gone a little overboard here, but I'm setting every flag that I've seen suggested and I'm still not seeing what I'm expecting. Does anyone have any ideas?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Did you try with QStackedLayout with StackingMode set to StackAll ?

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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