A strange problem with QOpenGLWidget and QAXWidget



  • when i use qopenglwidget and qaxwidget in qt,i meet a strange problem that qopenglwidget does not show correctly.i dont know why.the code is like that:

    QTabWidget *tt=new QTabWidget;
    MyOpenGLWidget *openGL = new MyOpenGLWidget ();
    QAxWidget *native = new QAxWidget();
    native->setControl(QStringLiteral("{f587310d-5306-494d-87e2-88334b46e781}"));
    native->setAttribute(Qt::WA_NativeWindow);
    native->setAttribute(Qt::WA_DontCreateNativeAncestors);
    tt->addTab(native,"n");
    tt->addTab(openGL,"o");

    MyOpenGLWidget inherit from QOpenGLWidget and has an override method paintEvent,like:
    void MyOpenGLWidget ::paintEvent(QPaintEvent *event)
    {
    QPainter painter;
    painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.fillRect(event->rect(), QColor(255,255,0));
    painter.end();
    }
    and i also set app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); in main function
    the problem is
    1.the background of MyOpenGLWidget is black´╝înot yellow that i expect
    2.when i change
    tt->addTab(native,"n");
    tt->addTab(openGL,"o");
    to
    tt->addTab(openGL,"o");
    tt->addTab(native,"n");
    MyOpenGLWidget show right

    i create a test project in https://github.com/hankern/Test-QOpenGLWidget



  • i think the context of qaxwidget affects the context of qopenglwidget,but how can i assign a new context for qopenglwidget


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.