Results 1 to 13 of 13

Thread: No action checked in an exclusive action group

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question No action checked in an exclusive action group

    Hi, I have a group of two exclusive actions with a QActionGroup. Both actions are checkables. The problem is that if I press under an action that is checked, the action continues checked but what I really want is to uncheck it. The only way to uncheck an action is by pressing the other action of the group. Is it a simple way of doing what I want without add a new slot? Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No action checked in an exclusive action group

    Call setExclusive(false) on the action group.

  3. #3
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: No action checked in an exclusive action group

    Finally what I have done is connect, for both actions, the signal toogled of an action with the slot setdisabled of the other action

  4. #4
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by SkripT
    Finally what I have done is connect, for both actions, the signal toogled of an action with the slot setdisabled of the other action
    Seems a bit 'brute force'. Didn't my solution work?

  5. #5
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: No action checked in an exclusive action group

    Sorry that I reply too late but I thought that the solution would be ok, but don't and I didn't read again the htread

    Quote Originally Posted by Chicken Blood Machine
    Seems a bit 'brute force'
    That's exactly the problem

    Quote Originally Posted by Chicken Blood Machine
    Call setExclusive(false) on the action group.
    I need the two actions being exclusive: if I activate an action I want to inactivate the other action. The problem is that if I push under an activated (checked) action, the action remains activated but what I really want is to disactivate it. I would like to know if it's possible to make it easily connecting only the signals and slots provided with QAction. I think that the solution should be something like: Dont' put the actions in an action group and when a signal toggled(true) is recevied of some of both actions I have to call setChecked(false) of the other action.
    Another problem that I noticed is that if I put both actions in an exclusive action group and I push under a checked action, the button of the action is painted like if I was pushing it to activate it again but no signal (toggled or triggered) is emited I suppose that 's beacuse the state of the action hasn't changed, but should be a way to know if the action has been pushed again...


    Thanks.
    Last edited by SkripT; 11th February 2006 at 11:45.

  6. #6
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by SkripT
    Sorry that I reply too late but I thought that the solution would be ok, but don't and I didn't read again the htread


    That's exactly the problem



    I need the two actions being exclusive: if I activate an action I want to inactivate the other action. The problem is that if I push under an activated (checked) action, the action remains activated but what I really want is to disactivate it. I would like to know if it's possible to make it easily connecting only the signals and slots provided with QAction. I think that the solution should be something like: Dont' put the actions in an action group and when a signal toggled(true) is recevied of some of both actions I have to call setChecked(false) of the other action.
    Another problem that I noticed is that if I put both actions in an exclusive action group and I push under a checked action, the button of the action is painted like if I was pushing it to activate it again but no signal (toggled or triggered) is emited I suppose that 's beacuse the state of the action hasn't changed, but should be a way to know if the action has been pushed again...


    Thanks.

    I think there is a confusion about what 'exclusive' means. If two (or more) buttons are exclusive then one of them should always be checked. Therefore pushing one that is already checked should not deselect it and should not fire any signal because the state has not and should not change.

    The behaviour that you descibe above is bizarre and non-standard and yes, you will have to code it yourself somehow.
    Save yourself some pain. Learn C++ before learning Qt.

  7. #7
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by Chicken Blood Machine
    The behaviour that you descibe above is bizarre and non-standard ...
    If I want this behaviour is because I have seen it in many appliactions. If you are using Windows XP take a look at the Microsoft Photo Editor program. The behaviour of the buttons to select an area of the image and to define the transparent color follow this behaviour. As you see it's not as bizarre and non-standard as you comment...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No action checked in an exclusive action group

    The fact that it is used in one application (even if it is a popular one), doesn't automatically make it "standard".

  9. #9
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by SkripT
    If I want this behaviour is because I have seen it in many appliactions. If you are using Windows XP take a look at the Microsoft Photo Editor program. The behaviour of the buttons to select an area of the image and to define the transparent color follow this behaviour. As you see it's not as bizarre and non-standard as you comment...
    I don't think I have Microsoft Photo Editor on Windows XP - regardless - proof by selected example is no proof at all. The writers of MS photo editor probably had to speciifcally code that behaviour too :-)
    Save yourself some pain. Learn C++ before learning Qt.

  10. #10
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: No action checked in an exclusive action group

    You are right, but I dont' think that the behaviour that I comment is a strange behaviour. Basically is the same that having a group of exclusive actions with the only difference that I want that the activated/checked action could be unchecked without having to check another action. That's all. Finally I have solved it with a new slot.
    Last edited by SkripT; 12th February 2006 at 01:00.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No action checked in an exclusive action group

    The thing you want can be easily achieved by adding another item titled "None of the above".

  12. #12
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by wysota
    The thing you want can be easily achieved by adding another item titled "None of the above".
    Yes that's the other solution that I was managing too. I have to decide which of both I will put on the final app. Thanks.

  13. #13
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No action checked in an exclusive action group

    Quote Originally Posted by SkripT
    You are right, but I dont' think that the behaviour that I comment is a strange behaviour. Basically is the same that having a group of exclusive actions with the only difference that I want that the activated/checked action could be unchecked without having to check another action. That's all. Finally I have solved it with a new slot.
    Well then they're definitely not 'exclusive'. I'm glad you found a solution for your problem though.
    Save yourself some pain. Learn C++ before learning Qt.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.