8

I use designer to build my GUI and load the saved xml in a python script. I've been using QGroupBox to contain radio buttons but would prefer to use QButtonGroup. The problem is that QButtonGroup is not available in the 'Widget Box' within the designer interface. Is there an alternative method to place a QButtonGroup object is designer? Or perhaps there is a way to add QButtonBox to the Widget Box?

Hope my question is clear.

BlackBear
  • 81
  • 1
  • 4
  • 2
    QButtonGroup is not a container, it is not a visible element that does not handle Qt Designer, so you will have to do it by code – eyllanesc Oct 18 '18 at 18:36
  • Thanks eyllanesc. I see now that I can 'assign' items to a QButtonGroup from within designer. If one of the buttons is right clicked there is an option in the pop up menu to "Assign to button group". Then designer will create the button group. – BlackBear Oct 18 '18 at 19:59
  • I also see it recently, I recommend you publish an answer indicating it and mark it as correct. – eyllanesc Oct 18 '18 at 20:45
  • eyllanesc, How to 'publish' your answer and mark it as correct? – BlackBear Oct 22 '18 at 19:32
  • read the [tour] – eyllanesc Oct 22 '18 at 19:34
  • Hi eyllanesc and thanks again. Despite what your reference tour says I do not see any options for up voting answers or marking them in any way. Only an option to up vote questions. With respect to answers all I see is an option to flag them. – BlackBear Oct 24 '18 at 14:57
  • @eyllanesc is there a way to setExclusive() in QButtonGroup in Qt Designer for Python ?? – pippo1980 Apr 07 '22 at 18:48
  • @eyllanesc, never mind found autoExclusive flag in the properties of each QCheckBox I put in my QButtonGroup, so to be able to create autoexclusive or non autoexclusive CheckBoxes in my QButtonGroup – pippo1980 Apr 07 '22 at 19:03
  • 1
    To anybody reading this so late: please consider the tools you're using and their names. It's called a *widget box*: a "button group" isn't a widget, it's an abstract concept that *groups* buttons, so you obviously cannot *add* it to a UI that manages visual objects as you'd do with other similar objects. I know that some confusion may raise considering that that box also includes "layouts", but that's a very different aspect: layouts manage their own, closely related objects, while button groups could include widgets that are visually and conceptually extremely far away from their "siblings". – musicamante Jan 05 '23 at 04:36

1 Answers1

14

Ctrl-Click the buttons you want to assign to the group, then right-click one of them, and select "Assign to button group"

shahard
  • 181
  • 1
  • 4
  • 2
    Nothing happens after selecting New (the only selection available). How can I enter a name for the new group? I am using version 5.9.7. – Günter Jul 11 '21 at 22:44
  • 2
    @Günter the new group appeared to me at the end of "Object Inspector" list. You can change the group's name there. – Helder Aug 20 '21 at 13:52