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 righti create a test project in https://github.com/hankern/Test-QOpenGLWidget