Checkable action does not set button checkd



  • Hi,

    shouldn't a checkable QAction also set its state to a control which it is added to? E. g. a button where the action is added to through addAction?

    bf



  • It is just a action added QWidget. Widgets can have many actions. Not just one action. What is the basis for changing the state of widget to which it is added ? It is not one-to-one mapping. QAction is mainly used with context menus or menu items. So there are always multiple actions associated with main widget. May be you have specific use case just with Button and QAction. In generic usage it does not fit in.



  • I am aware of that but what sense does it make then that an action can be checkable? If it is that generic and so on this property does not really make sense to me because I have to take care of that state anyway. Especially this property would make it less general for me (e. g. it does not support tristate).


  • Lifetime Qt Champion

    Hi,

    In order to sync a checkable button and a checkable action, typically you would connect the action toggled signal to the setChecked slot of the button. And also vice-versa



  • @SGaist: Thanks for that advice. Synchronizing them is actually not the problem. It is more questioning the design or asking for the background of that.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.