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. QOpenGLWidget cannot be used as a native child widget.
QtWS25 Last Chance

QOpenGLWidget cannot be used as a native child widget.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.8k 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.
  • Paul H.P Offline
    Paul H.P Offline
    Paul H.
    wrote on last edited by
    #1

    Hello,
    I have been working on learning to use Qt (5.5 on Windows 7) to develop applications using OpenCascade. I am also just learning OpenCascade, as well, so please bear with me.

    I found this page with this code which uses QGLWidget. I got it to build and run as it should, but I tried changing the QGLWidget to QOpenGLWidget and get this message repeating in the Application Output while running:
    QOpenGLWidget cannot be used as a native child widget. Consider setting Qt::AA_DontCreateNativeWidgetAncestors and Siblings.

    The program runs, but the Menu bar and Toolbar don't show anything until I click the mouse in an area where there should be a button showing in the toolbar. Then everything appears as it should, but that message still constantly appears in the Application output.

    I added a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); to main.cpp as shown here:
    (There doesn't appear to be a Qt::DontCreateNativeWidgetAncestors.)

    #include "occQt.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
        occQt w;
        w.show();
        return a.exec();
    }
    

    That fixed the issue with the toolbar and menu visibility, but I still get the same messages. Is there something else I need to do to switch from QGLWidget to QOpenGLWidget? Like I said, I'm just learning so I want to know how to do it the correct way.
    Thank you,
    Paul

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brcha
      wrote on last edited by
      #2

      QGLWidget allowed for old OpenGL code (<2.0) to be used. On the other hand, QOpenGLWidget doesn't (and it is not allowed in Qt 5.5 at all).

      While I have no idea what's wrong with your app, I do think it has something to do with deprecation of old OpenGL. Try compiling it with Qt 5.3.x. If it does compile&run, you'll know where the problem is.

      Paul H.P 1 Reply Last reply
      0
      • B brcha

        QGLWidget allowed for old OpenGL code (<2.0) to be used. On the other hand, QOpenGLWidget doesn't (and it is not allowed in Qt 5.5 at all).

        While I have no idea what's wrong with your app, I do think it has something to do with deprecation of old OpenGL. Try compiling it with Qt 5.3.x. If it does compile&run, you'll know where the problem is.

        Paul H.P Offline
        Paul H.P Offline
        Paul H.
        wrote on last edited by Paul H.
        #3

        @brcha said:

        QGLWidget allowed for old OpenGL code (<2.0) to be used. On the other hand, QOpenGLWidget doesn't (and it is not allowed in Qt 5.5 at all).

        Try compiling it with Qt 5.3.x.

        I'm not sure I understand what you are getting at. I can still use QGLWidget in 5.5, and the program will build and run correctly using it. I just didn't want to start learning Open Cascade with Qt using an obsolete module. For now I guess I'll try starting with one of the qt OpenGL examples and see if I can add the Open Cascade functionality to that with better results.
        Thanks for the reply!
        Paul

        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