flamaros
21st February 2013, 17:08
I am trying to display a QDeclarativeView in front of QGLWidget, to create contextual menus,...
Here is my code:
QApplication::setGraphicsSystem("opengl");
....
RenderWidget* renderWidget = new RenderWidget; // RenderWidget is the QGLWidget
QDeclarativeView *qmlView = new QDeclarativeView(renderWidget);
qmlView->setSource(QUrl::fromLocalFile("qml/main.qml"));
qmlView->setStyleSheet(QString("background: transparent"));
qmlView->setAutoFillBackground(false);
qmlView->setPalette(Qt::transparent);
QVBoxLayout *layout = new QVBoxLayout(renderWidget);
layout->setMargin(200); // reducing size to view to 3D scene behind
layout->addWidget(qmlView);
setCentralWidget(renderWidget);
resize(640,480);
With this code my qml is display in front of the 3D scene, but the layout is rendered with full opacity. When I use gDEBugger I see that the QDeclarativeView use an other openGL context than my 3D engine, and a texture containing the result of the qml view.
The texture of the qml view seems correct (with appropriate alpha zones)
I suppose the blit is completly software, when I am expecting an hardware one because I call QApplication::setGraphicsSystem("opengl"); before the QApplication initialization.
Is there a way to force the QDeclarativeView to share his opengl context with those of QGLWidget?
Added after 29 minutes:
When I remove the layout the result is exactly the same.
Here is my code:
QApplication::setGraphicsSystem("opengl");
....
RenderWidget* renderWidget = new RenderWidget; // RenderWidget is the QGLWidget
QDeclarativeView *qmlView = new QDeclarativeView(renderWidget);
qmlView->setSource(QUrl::fromLocalFile("qml/main.qml"));
qmlView->setStyleSheet(QString("background: transparent"));
qmlView->setAutoFillBackground(false);
qmlView->setPalette(Qt::transparent);
QVBoxLayout *layout = new QVBoxLayout(renderWidget);
layout->setMargin(200); // reducing size to view to 3D scene behind
layout->addWidget(qmlView);
setCentralWidget(renderWidget);
resize(640,480);
With this code my qml is display in front of the 3D scene, but the layout is rendered with full opacity. When I use gDEBugger I see that the QDeclarativeView use an other openGL context than my 3D engine, and a texture containing the result of the qml view.
The texture of the qml view seems correct (with appropriate alpha zones)
I suppose the blit is completly software, when I am expecting an hardware one because I call QApplication::setGraphicsSystem("opengl"); before the QApplication initialization.
Is there a way to force the QDeclarativeView to share his opengl context with those of QGLWidget?
Added after 29 minutes:
When I remove the layout the result is exactly the same.