PDA

View Full Version : How to raise a QWidget over QGraphicsObjects in a QGraphicsScene



sedi
7th April 2012, 23:54
Hi,
I'm using a QGraphicsScene with several QGraphicsObjects of different zValue.
Now I have made a Control Widget (a few QPushbuttons and QComboBoxes and Layouts on a QWidget) with QCreator and added it to the

QGraphicsScene with scene->addWidget(controlWidget);
The problem is: the widget is being overlapped by most of the other objects in the scene.

I tried the QWidget::raise(); method to no avail at all. Is there any way to make QWidget appear in front of all QGraphicsScene members?
I cannot ensure that the widget is addet as last member to the scene.

I am running out of ideas :-( Any help is welcome, thank you for reading!

Sebastian

norobro
8th April 2012, 02:50
Try giving your controlWidget a zValue higher than your other items:
QGraphicsProxyWidget *proxyWidget = scene()->addWidget(controlWidget);
proxyWidget->setZValue(1000); // or 10000 or . . .

sedi
8th April 2012, 12:25
Norobro, thank you so much! My forehead aches big deal from being smashed on the table continuously for quite some time. "The very moment you do something the right way, it suddenly works". Like a charm. Thanks a ton! :)