[bt-devel] Switch QAction state without events

Patrick Zimmermann patrick at zakweb.de
Tue Apr 3 13:46:23 MST 2012


Hi,

I'm currently hunting a bug in session restore.
Most actions in the view menu don't restore their state.

The problem I face now is that I need to switch the state of the QActions (to 
change them to what the config says) without triggering the events they are 
associated with. As far as I searched, QActions themselves don't provide a 
feature for this.

The three possible solutions that came to my mind are:
1. Disconnecting the QActions, switching their state and reconnecting again.
2. Put an if(actionsEnabled) {} in all functions the actions are connected 
with to allow temporarilly turning them of.
3. Check whether the QAction and reality are different and if yes call the 
callback function manually once to get them in line before switching them to 
the correct state.

All three seem somewhat ugly to me. With the third being the best according to 
my taste.
Are there any better ideas/typical approaches of doing this?

Greetings
Patrick



More information about the bt-devel mailing list