PDA

View Full Version : An interesting problem when using QMenu::aboutToShow() signal!!



srazi
19th August 2011, 17:38
I subclass QToolBar and create some QToolButtons and create and set menu for every QToolButton, all things work good until I connect 'QMenu::aboutToShow()' to a 'SLOT'!! And then I see that menus are showed in an incorrect position!!!
when I looked at 'qtoolbutton.cpp' I see this code:


void QToolButtonPrivate::popupTimerDone()
{
...
QPoint p;
QRect screen = QApplication::desktop()->availableGeometry(q);
QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
QRect rect = q->rect();
...
//computing 'p'! 'sh' is used in this computation
...
actualMenu->exec(p);
...
}

I can't understand using 'QObject::receivers(const char *signal)' in such a bad way!!!!! Why we should get different results just because of creating a connection!!!!?
It's unbelievable... :confused:

For solving the problem I use 'QEvent::Show' in replace of 'QMenu::aboutToShow()'!

mvuori
19th August 2011, 21:26
Every library ever created contains many unbelieveable things. And I mean it literally.

Sending a neutral bug report might advance things.