How to copy the content of a QPopupMenu ?

Diez B. Roggisch deets at nospam.web.de
Wed Apr 5 09:21:19 EDT 2006


kobayashi at netcourrier.com wrote:

> Dear Diez,
> 
> Thanks ... I've already read the doc :)
> 
> 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 ...
> 
> 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)

Your approach at whole must be changed. You can't just insert the old items
somewhere else - they have a 1:n parent-relation that would be changed -
either crashing, or simply removing your item from your old menu.

What you need is a different means to create the items - some
factory/function that gets passed a QPopupMenu and adds all the items,
together with the connectrions and so on. You then invoke that on the other
menu.

Diez



More information about the Python-list mailing list