PDA

View Full Version : QGLWidget and transparent widgets



blizniak83
10th April 2012, 17:00
Hi,

I've got simple GLWidget class inherited from QGLWidget where I render some simple geometry. I instantiate the object of my GLWidget class inside MainWindow, where I display all widgets associated with GLWidget, like QSliders, QPushButtons to interact with the openGL scene. I have two options, I can embed the GLWidget inside my GUI or just show as a separate widget using show() function. Everything works fine. Recently I tried to add some transparent widgets over the GLWidget, like transparent QDialog or QPushButton. I tried to achieve that using similar approach to the one presented in - 'boxes' project from Qt demos,
using QGraphicsView and QGraphicsScene. Everything is fine when I try to show the widget inside main.cpp, but when I try to show it inside the MainWindow, something is not right, as the widget appears and disappears very quickly and the rest of the interface - everything what is inside MainWindow is displayed properly, but the QGraphicsView is not displayed.

Example code:


QTabWidget *tabWidget = new QTabWidget;

QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);

QGraphicsView view(&scene);
view.show();

The above code works fine in main but doesn't in MainWindow.

I would be very grateful if someone could help me to fix that problem, if not I am happy to try something different
to add transparent widgets on top of QGLWidget. Any suggestions?

Thank you.

Krzysztof