[Qt-interest] Can a QAction be replaced at runtime ?

Stephen Collyer scollyer at netspinner.co.uk
Tue May 12 19:55:35 CEST 2009


2009/5/12 Scott Aron Bloom <Scott.Bloom at sabgroup.com>

>  Depending on the complexity of the replacement, yours is a fine solution…
>
>
>
Well, in my simple case, it's fine, but I'd prefer to have a more scalable
solution to hand if possible.


> You may also want to have 1 slot, and use QSignalMapper, and you rebuild
> the menu each time it is about to be shown (using signal
> QMenu::aboutToShow() )
>
>
OK. That looks like a fairly interesting approach. I wasn't aware of
QSignalMapper.
However, in order to rebuild the menu, you need to use state from the rest
of the system, I guess, rather than the state residing in the menu itself
(i.e. my approach ensures that an already started activity can't be
restarted since the start action is no longer available in the menu).

> Or, I have been known to change the text of a single QAction based on
> state..  My slot becomes a bit more complex, but QAction::setText should do
>
>
Yes, I thought of that. It's no better or worse than my "insert and remove"
approach, AFAICS.

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090512/39f1dade/attachment.html 


More information about the Qt-interest-old mailing list