Controlling the direction of a QComboBox's drop-down menu
-
Is there any way to choose if the drop-down menu should appear bellow or above the QComboBox?
I have a QComboBox at the bottom of a page and when I click it the menu drops below the box and only shows one item and a scroll-bar. Would like it to appear above the box instead.
Using QT 3.3.6
-
One solution to explore is :
- creating a subclass of QComboBox ;
- reimplementing the QComboBox::showPopup() function.
However, if you look at showPopup source-code, you'll see that they use a lot of private stuff (pimpl), so you won't have access to it in your class, since it's private and not protected.
The way to go would then be to move the view used to render the popup. You can access it by calling QComboBox::view(). It should then give something like :
@
void MyComboBox::showPopup()
{
QAbstractItemView *popupView = view();
popupView->move(...);QComboBox::showPopup();
}
@ -
unfortunately showPopup() and view() is not available i version 3.3.6 and updating to a new version of Qt is not an option
[quote author="octal" date="1314262343"]One solution to explore is :
- creating a subclass of QComboBox ;
- reimplementing the QComboBox::showPopup() function.
However, if you look at showPopup source-code, you'll see that they use a lot of private stuff (pimpl), so you won't have access to it in your class, since it's private and not protected.
The way to go would then be to move the view used to render the popup. You can access it by calling QComboBox::view(). It should then give something like :
@
void MyComboBox::showPopup()
{
QAbstractItemView *popupView = view();
popupView->move(...);QComboBox::showPopup();
}
@[/quote] -
[quote author="buggex" date="1314270208"]unfortunately showPopup() and view() is not available i version 3.3.6 and updating to a new version of Qt is not an option
[/quote]
No, but according to the docs, you do have a virtual popup() method and a method that returns a listBox() method. That is basically the Qt 3 version of showPopup() and view().