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. Wrapping a QOpenGLWidget in a QAbstractScrollArea
QtWS25 Last Chance

Wrapping a QOpenGLWidget in a QAbstractScrollArea

Scheduled Pinned Locked Moved General and Desktop
qabstractscrollqopenglwidgetopengl
1 Posts 1 Posters 701 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.
  • C Offline
    C Offline
    Connor Skennerton
    wrote on last edited by
    #1

    When I set a subclass of QOpenGLWidget as the viewport to a QAbstractScrollArea it seems a lot of the initialization for the widget does not happen.

    I have two classes

    class ScrollCanvas : public QAbstractScrollArea
    

    and

    class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
    

    ScrollCanvas has a GLWidget as a member and I set it to the viewport using setViewport(glWidget);

    In QAbstractScrollArea there is a function setupViewport where I can initialize the viewport after it's set. In this function I call initializeGL() from GLWidget. However the call to initializeOpenGLFunctions();, which is the first thing in initializeGL() causes a crash. I put a print statement just above this line and printed the address of the QOpenGLContext and found that it was set to 0.

    When the GLWidget is not set as the viewport of the QAbstractScrollArea the QOpenGLContext has a valid memory address at this point. So it seems that a function is not being called during the initialization of the widget. Can anyone tell me what initialization needs to occur before initializeGL() such that the QOpenGLContext is valid?

    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