Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, May 2007
QMenu::removeAction(QAction *) disconnects the QAction?


Message 1 in thread

Hello.

While writing an application with dynamic menus, it seems to me that
QMenu::removeAction(QAction *) disconnects that QAction from any signals
and slots it may be connected to.  I couldn't find anything in the
documentation about this.  Is this the expected behaviour?  I would
think that a QAction removed from a menu and then added to another would
retain its connections.

I know QMenu::clear() deletes any QActions that aren't attached to
anything else (which would obviously disconnect them from any slots and
signals), but removeAction() doesn't delete the action, so I'm not clear
on why the slots and signals are disconnected.

-- 
 [ signature omitted ] 

Message 2 in thread

darrik mazey wrote:
> While writing an application with dynamic menus, it seems to me that
> QMenu::removeAction(QAction *) disconnects that QAction from any
signals
> and slots it may be connected to.  I couldn't find anything in the
> documentation about this.  Is this the expected behaviour?  I would
> think that a QAction removed from a menu and then added to another
would
> retain its connections.
> 
> I know QMenu::clear() deletes any QActions that aren't attached to
> anything else (which would obviously disconnect them from any slots
and
> signals), but removeAction() doesn't delete the action, so I'm not
clear
> on why the slots and signals are disconnected.

Just an idea: what did you set as parent for the action?
If it's the menu you're removing it from, that could be the cause of the
problems.

See QAction docs:
"We recommend that actions are created as children of the window they
are used in. In most cases actions will be children of the application's
main window."

Cheers,
Peter


--
 [ signature omitted ]