How to have checkbox or Toggle behavior for QAction in QActionGroup

  • I have QActionGroup in Which I adding various Qactions

    QAction d_actionView1 = new QAction();
    QAction d_actionView2 = new QAction();
    QActionGroup_viewGroup = new IN_CURRENT_POOL QActionGroup(this);

    I want to have toggle behaviour for each d_actionView1 and d_actionView2 . Can we have check boxes for the same to have toggle behaviour for the same

  • Moderators

    set the action group to exclusive.
    The widget which then displays (using the platform style) decides how to present it.

    A menu for example should draw radiobuttons IIRC

  • I want a checkbox so that user can select multiple actions at one time . For example

    QAction d_actionView1 = new QAction();
    QAction d_actionView2 = new QAction();

    user should be able to select d_actionView1 and d_actionView2 at same one time

  • @Qt-Enthusiast
    But doc says

    only one of these actions should be active at any one time.

  • Moderators

    well this is very special application logic i would say. So you need to take care of it.
    Connect to QActionGroup's triggered(QAction*) signal and check the action. Then you can set the other action also to de-/selected.

    yes, only when it's set to exclusive.

  • is it possible to change the bacground color of the QAction when want to show the toggled behavior

  • so default we can have mutiple QActions selected at one time . does they behave a radio buttons if yes why

Log in to reply

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