Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QRadioButton and QGroupBox
Forum Updated to NodeBB v4.3 + New Features

QRadioButton and QGroupBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I was previously using a QButtonGroup and when using this the group function of the radio button does return the group, however this isn't the case when using QGroupBox. I understand from searching online that QGroupBox replaces QButtonGroup. Am I wrong...again?

    Kind Regards,
    Sy

    JonBJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I was previously using a QButtonGroup and when using this the group function of the radio button does return the group, however this isn't the case when using QGroupBox. I understand from searching online that QGroupBox replaces QButtonGroup. Am I wrong...again?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @SPlatten
      QGroupBox does not require QButtonGroup.

      QGroupBox is a visual element. You can visit all widgets inside it if you wish.

      QButtonGroup is a logical element. It does not render anything to the screen. It is used purely to group and access a bunch of widgets in a logical fashion. It only accepts radiobuttons/checkboxes, and is principally convenient for dealing with them where you only want one element in the group to be checked.

      [I forgot to say: If it suits your coding, there is nothing to stop you having a QGroupBox (for visuals) and a QButtonGroup (for logical handling) if you wish. The latter makes it easier to address the child elements than in the former, though you can manage without it and deal with the group box's children instead.]

      SPlattenS 1 Reply Last reply
      4
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        Think about you have more than one set of radio buttons in one group box. What will happen?

        SPlattenS 1 Reply Last reply
        0
        • JonBJ JonB

          @SPlatten
          QGroupBox does not require QButtonGroup.

          QGroupBox is a visual element. You can visit all widgets inside it if you wish.

          QButtonGroup is a logical element. It does not render anything to the screen. It is used purely to group and access a bunch of widgets in a logical fashion. It only accepts radiobuttons/checkboxes, and is principally convenient for dealing with them where you only want one element in the group to be checked.

          [I forgot to say: If it suits your coding, there is nothing to stop you having a QGroupBox (for visuals) and a QButtonGroup (for logical handling) if you wish. The latter makes it easier to address the child elements than in the former, though you can manage without it and deal with the group box's children instead.]

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #4

          @JonB, thank you

          Kind Regards,
          Sy

          1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            Think about you have more than one set of radio buttons in one group box. What will happen?

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @JoeCFD The behaviour is the same, adding the radio buttons with the same parent forms the group. I have 5 radio buttons in each group, only one can be selected, each group can have a different selection.

            Kind Regards,
            Sy

            JoeCFDJ 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @JoeCFD The behaviour is the same, adding the radio buttons with the same parent forms the group. I have 5 radio buttons in each group, only one can be selected, each group can have a different selection.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              @SPlatten For example: you lay out 5 radio buttons in a group box: 3 are mutually exclusive and the other two are the same. In this case, you need two qbuttongroups for the three and two radio buttons. If all five are mutually exclusive, qbuttongroup is not needed.

              The buttons in a button group are usually checkable QPushButtons, QCheckBoxes (normally for non-exclusive button groups), or QRadioButtons.
              https://doc.qt.io/qt-5/qbuttongroup.html#details

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved