Results 1 to 5 of 5

Thread: How to make QPushbuttons with same parent non-exclusive

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default How to make QPushbuttons with same parent non-exclusive

    I've been struggling with how to get a collection of toggling QPushbuttons (not checkboxes) that aren't exclusive. Each button should be checkable regardless of the state of the other buttons.

    I've set "checkable" and tried both autoexclusive on and off.

    I think I need them in some kind of container, since I want to use the group in several places in the GUI. They are in a vertical layout now.

    I read about QButtonGroup, but I don't see one of those in Qt Designer that I could try out.

    Is QButtonGroup what's needed to get non-exclusive QPushButtons? Can I get one from Qt Designer, or do I need to just add it in the code myself?

    Thanks,

    Dave Thomas

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

    Default Re: How to make QPushbuttons with same parent non-exclusive

    Where did you place those buttons? I mean what is their parent widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to make QPushbuttons with same parent non-exclusive

    I just dropped three default QPushButtons on a generic QWidget parent in Designer, marked them all checkable, and the default behaviour is that they operate independently as you are asking for. The same is true for a default QGroupBox container. What container are you using?

    You can access QButtonGroup in Designer but it is not immediately obvious. Select the push buttons you want in the group, right click for the context menu and select "Assign to button group...". The default behaviour of the group is to make the buttons exclusive, precisely the opposite of the default behaviour and your required behaviour.

  4. #4
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make QPushbuttons with same parent non-exclusive

    Their parent was a vertical layout in the central widget of a mainWindow.

    I figured out how to add them to a QButtonGroup and when I unchecked that group's exclusive property, I got what I want.

    Thanks,

    Dave Thomas

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to make QPushbuttons with same parent non-exclusive

    The layout does not own the widgets is controls layout for; they are owned by a QWidget. If you do not parent the widgets explicitly then their parent is set by the layout when you apply it to a container.

Similar Threads

  1. How to make plainTextEdit autofill to parent window?
    By kid2000 in forum Qt Programming
    Replies: 7
    Last Post: 17th February 2009, 09:59
  2. Replies: 2
    Last Post: 19th August 2008, 09:46
  3. how exclusive toolbutton in toolbar
    By irmakci in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2008, 22:33
  4. exclusive checkBox
    By mickey in forum Qt Programming
    Replies: 6
    Last Post: 4th October 2007, 18:26
  5. Replies: 1
    Last Post: 14th May 2007, 14:55

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
  •  
Qt is a trademark of The Qt Company.