PDA

View Full Version : [QComboBox] problem with popup position



Auliyaa
12th January 2012, 10:27
Hi everyone,

I'm currently working with the QGraphicsView framework and I'm embedding some widget in a scene where some graph drawing is done.
My embedded widget is meant to be a quick access bar anchored to the bottom of the scene. I added a QGraphicsProxyWidget to my scene and I move it to the bottom of the scene every time the QGraphicsView widget gets resized.
Everything worked perfectly until I decided to add a QComboBox in my bottom bar. When I click on the combo label, the popup always shows up at the bottom of the QComboBox. Except it should be displayed on top of the combo box since my widget is located at the very bottom of my application. Here's a screenshot of what happens:

7259
Note: The red square shows the actual area on which the popup is expanded.

So my question is: Is there a way to force the QComboBox's popup position either by subclassing QComboBox or with some stylesheet configuration ?

I checked the QComboBox::showPopup() method already but reimplementing it would mean re-writing all the code concerning the actual creation of the popup widget and I'd rather avoid that.

Any suggestion ?

wysota
12th January 2012, 21:11
So my question is: Is there a way to force the QComboBox's popup position either by subclassing QComboBox or with some stylesheet configuration ?
Widgets in GraphicsView are inherently broken when it comes to respecting your desktop. If you subclass you should be able to make it work however it is hard to say how much work needs to be done.


I checked the QComboBox::showPopup() method already but reimplementing it would mean re-writing all the code concerning the actual creation of the popup widget and I'd rather avoid that.

It's not that bad. The popup is there, you just need to access it. Either look in Qt source code to see how it is called and use qFindChild() or try your luck with calling view()->parent().

Auliyaa
16th January 2012, 07:48
Thanks for your reply ^^

The QComboBox's popup is located in the d pointer of the combo box. Which means that you need to use the Qt private headers to be able to use it. Unfortunately, we cannot force such a dependency into our software. I think I'm just going to provide my own popup to control position.

wysota
16th January 2012, 09:27
The QComboBox's popup is located in the d pointer of the combo box. Which means that you need to use the Qt private headers to be able to use it.
No, that's not true. The widget is a child of the combobox and not the "d" pointer since the latter is not a QObject so regardless where it is stored, you can access it using qFindChild().


QWidget *popup = comboBox->findChild<QFrame*>(); // here is your popup