Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QOpenGLWidget cannot be used as a native child widget.



  • 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



  • 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.



  • @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


Log in to reply