PDA

View Full Version : how to check the popup direction in qcombobox



wagmare
6th November 2013, 07:30
hi friends,
is there any way to check the popup direction of qcombobox . is it any way to check the popup drops up or down ..

aamer4yu
6th November 2013, 08:16
I guess it happens automatically. Why you need to check manually ?

For details check the source code of QComboBox::showPopup

wagmare
6th November 2013, 09:10
I guess it happens automatically. Why you need to check manually ?

For details check the source code of QComboBox::showPopup
my combobox adjust only after i add the forth item in my combobox .. im having some space below where the combobox is placed .. so initial three items will pop down but my requirement is to show pop upwards all the time ..
actually i have to show the popup in drop up even before qt adjust the orientation .. so i tried this

:showPopup()
{
QComboBox::showPopup();
QWidget *popup = this->findChild<QFrame*>();


popup->move(popup->x(),popup->y()-this->height()-popup->height())


it works .. but when qt adjust the orientation my calculation of move() is going in wrong ..for that reason only im asking if any possible way i can detect ..

anda_skoa
6th November 2013, 10:08
Well, you could first check if the popup's top left is above or below the combobox's rectangle, no?

Cheers,
_

wagmare
6th November 2013, 10:53
done thx!

qreal yPos = mapToGlobal(this->rect().topLeft()).y();
if(popup->y() > yPos)