QAction-related problems/needs

Thiago Macieira thiago at
Wed Apr 5 00:30:25 BST 2006

David Faure wrote:
>So this brings me to the following question: how do I add a widget to a
> menu? This doesn't seem to be available; only actions can be added to a
> menu. Hmm. Looking at qmenu.cpp ... it's worse than I thought. There
> are no widgets at all used internally for every "item"; it's all done
> by qstyle painting based on the action's text and icon :( Probably more
> efficient, but very unflexible compared to Qt3's QPopupMenu.
>Thiago: I remember a similar request on kde-devel, do you know if a TT
> task ended up being created for that? Although now that I see the code
> I see how this will never happen...

Isn't this what Hamish's patch (0119) is supposed to do? It associates an 
action with a widget factory.

>Argl, is there really no better solution?
>What used to be doable with one qlistbox subclass in qt3 would now
> require 
> - a kaction subclass 

I'd rather avoid this.

>- a qlistview subclass
>- a qabstractlistmodel subclass

Doesn't QListWidget suffice for you? Do you really have to write your own 

>- a qtoolbutton subclass

>The first three seem logical, but the latter is killing me; lots of code
> duplication. Maybe QToolButton's support for a "popup" could be
> generalized so that the popup isn't necessarily a QMenu, but any
> QWidget? Looking at the code I see little that actually requires a
> menu... except for the exec() call, but I guess the QMenu::exec() code
> could be done directly in qtoolbutton to "exec" any widget...
>Does this make sense, or am I overlooking anything? I guess my next step
>is to talk to TT about this and see if they (or I) can generalize
> QToolButton's idea of popups...

Right. If we can't find a simpler solution for this issue, then I'd like 
to see if we can easily solve it the Qt side, rather than having to write 
100s lines of code as workarounds.

We shouldn't have to workaround limitations. We should fix them, if 

Thiago Macieira  -  thiago (AT) - thiago (AT)
  thiago.macieira (AT)     Trolltech AS
    GPG: 0x6EF45358                   |  Sandakerveien 116,
    E067 918B B660 DBD1 105C          |  NO-0402
    966C 33F5 F005 6EF4 5358          |  Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list