Dependent actions



  • Is there some easy way to make set of dependent actions. I mean I have some QActions and need to enable only one action each time like in radiobuttons. Is there some solution to do this from Qt Designer ?


  • Moderators

    You mean like enabling an action after specific others have been enabled?



  • I mean when I check one action, others must be unchecked.


  • Moderators

    I see. This clarifies your question.
    May you can use "this":http://doc.qt.nokia.com/4.7/qabstractbutton.html#checkStateSet
    but I have to admit that I am struggling with the text as well. So far, I have done the connected actions myself.
    Let's see, if someone else has a solution. There must be one.


  • Moderators

    If the radio button example is what you need, you should have a "look":http://doc.qt.nokia.com/4.7/widgets-groupbox.html



  • I've got this actions on my main window toolbar thats why I can't place em to groupbox, cause I can't place groupbox in toolbar.



  • Why don't you group your QActions behind the buttons in a QActionGroup, and call QActionGroup::setExclusive(true) on that group?



  • Ok, I made that you said, Andre. it's work but I cant get QAction group triggered signal. Who knows why ? This signal is very useful for me because I can get current triggered action just by connect one signal. So, please look anyone is there something wrong in the code. Actions is on tool-bar I made this in designer, maybe I need to remove them and put action group on toolbar ?

    @QActionGroup * actionGrp = new QActionGroup(this);
    actionGrp->addAction(m_ui.actionPixelator);
    actionGrp->addAction(m_ui.actionErase);
    actionGrp->setExclusive(true);

    connect(actionGrp,SIGNAL(triggered(QAction)), this, SLOT(onActionChanged(QAction)));@

    I get this message: Object::connect: No such signal QActionGroup::triggered(QAction);

    Sorry, my mistake forgot to put '*' :)
    @connect(actionGrp,SIGNAL(triggered(QAction *)), this, SLOT(onActionChanged(QAction *)));@


Log in to reply
 

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