How to copy the content of a QPopupMenu ?

David Boddie david at boddie.org.uk
Wed Apr 5 09:41:48 EDT 2006


kobayashi at netcourrier.com wrote:  > In my case, I would like to copy an
item from > a popup menu to another popup menu ... Of course, > I can
create a new item with same name, same pixmap > and so on but I don't
know how to execute the same code > when my new item is activated ...
And I don't know how > to treat the separators (Is there a way to
distinguish a > real item from a separator ?) And what about the
sub-menus ...  You might want to use QAction to define individual items
that can be activated. That way you can just reuse the same actions in
both menus or move them from one to another.  Submenus will probably
take more effort to move. In some ways, it might be useful to keep some
sort of data structure around that you can use as a template for the
menu, and regenerate the menu from that.  > In fact, all items (usual
items, separators and sub-menus) are > ... items. So I was wondering if
it is a way to copy an item > (more precisely to get an item then to
insert it in another menu)  Not with one single operation as far as I
can see, unless you're using QAction, and even then it will only work
for normal menu items.  Aside: The Qt 4 action system probably makes it
a lot easier to do what you're trying to do, though that's not a lot of
help if your project is based on Qt 3. :-/  David




More information about the Python-list mailing list