KPushButton::setDelayedMenu

Dominik Haumann dhdev at gmx.de
Thu Sep 6 23:15:04 BST 2007


> > On Saturday 07 July 2007, Dominik Haumann wrote:
> > > KPushButton is pretty much broken with regard to the delayed menu
> > > capabilities. As QPushButton::setMenu is not virtual there is an
> > > additional function KPushButton::setDelayedMenu().
> > >
> > > When you hold down the button long enough a timer ticks which then
> > > adds the menu by using QPushButton::setMenu(delayed_menu).
> > >
> > > That's also the reason why KPushButton does not show the "down arrow"
> > > on the right side of the button even if you set a delayed menu. The
> > > arrow is shown when you hold down the button long enough. That means
> > > that there is no indication that the button has a delayed menu at
> > > all.

The not exported functions [re]setLayoutItemMargins (somewhere in Qt in 
gui/widgets/*) layout the icon and the text. This relayout is done without 
a menu.

The patch does 2 things:
1) sizeHint temporarily sets a menu, so the button's size is always correct
2) paintEvent temporarily sets a menu that QPushButton::painEvent draws the
   down-arrow.

However, in *both* cases the layout of the icon and the text is wrong: It is 
calculated as if the down-arrow would not exist -- when the relayouting 
stuff happens menu() returns 0, i.e. it really does not exist.

Without the patch, the user does not even have feedback that there is a 
drop-down menu. If he knows it, he gets a wrong layouted button.
With the patch, the down-arrow is there. But the layout is still always 
wrong.

Right now I don't see a solution, not even a really ugly hack. It simply 
doesn't work.

Maybe someone else can have a look?

Thanks,
Dominik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpushbutton.diff
Type: text/x-diff
Size: 1375 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070907/15916367/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpushbutton-without-patch.png
Type: image/png
Size: 12166 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070907/15916367/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpushbutton-with-patch.png
Type: image/png
Size: 13547 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070907/15916367/attachment-0001.png>


More information about the kde-core-devel mailing list