Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QButtonGroup difficulty
Qt 6.12 LTS is out! See what's new in the release blog

QButtonGroup difficulty

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 932 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.
  • Q Offline
    Q Offline
    qAlexKo
    wrote on last edited by
    #1

    Hi, All!
    Please help me with QButtonGroup.

    Suppose on my Qtcreator form I have (for instance) 50 radiobuttons united in one QButtonGroup
    When I quit my app I memories the active radiobutton index as an integer value in an ini file.

    When I ran my app again I read the saved index value for an ini file, and I wish to restore QButtonGroup status as it was before quitting.

    But how on earth I can do it?

    JonBJ 1 Reply Last reply
    0
    • Q qAlexKo

      Hi, All!
      Please help me with QButtonGroup.

      Suppose on my Qtcreator form I have (for instance) 50 radiobuttons united in one QButtonGroup
      When I quit my app I memories the active radiobutton index as an integer value in an ini file.

      When I ran my app again I read the saved index value for an ini file, and I wish to restore QButtonGroup status as it was before quitting.

      But how on earth I can do it?

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

      @qAlexKo
      By "active" radiobutton do you mean the one radiobutton which is selected in a group of 50 exclusives?

      checkedId() returns the id of the selected button. QButtonGroup::button(int id) returns the button with that id, to refind it at a later date. And probably QAbstractButton::click() can be used to click that button to reselect it when you restore, or maybe it's setChecked(true).

      https://gist.github.com/mistic100/dcbffbd9e9c15271dd14 seems to set the checked button. It does it by iterating every button for its id, I think QButtonGroup::button(int id) can be used to save you having to find it.

      Q 1 Reply Last reply
      1
      • JonBJ JonB

        @qAlexKo
        By "active" radiobutton do you mean the one radiobutton which is selected in a group of 50 exclusives?

        checkedId() returns the id of the selected button. QButtonGroup::button(int id) returns the button with that id, to refind it at a later date. And probably QAbstractButton::click() can be used to click that button to reselect it when you restore, or maybe it's setChecked(true).

        https://gist.github.com/mistic100/dcbffbd9e9c15271dd14 seems to set the checked button. It does it by iterating every button for its id, I think QButtonGroup::button(int id) can be used to save you having to find it.

        Q Offline
        Q Offline
        qAlexKo
        wrote on last edited by
        #3

        @JonB said in QButtonGroup difficulty:

        https://gist.github.com/mistic100/dcbffbd9e9c15271dd14 seems to set the checked button. It does it by iterating every button f

        OK it is a way out, thanx, although for me it is very strange that QGroupButton offers Checkedid() function to get the active button ID, and it can't set up the active button by a known ID. ;-)

        JonBJ 1 Reply Last reply
        0
        • Q qAlexKo

          @JonB said in QButtonGroup difficulty:

          https://gist.github.com/mistic100/dcbffbd9e9c15271dd14 seems to set the checked button. It does it by iterating every button f

          OK it is a way out, thanx, although for me it is very strange that QGroupButton offers Checkedid() function to get the active button ID, and it can't set up the active button by a known ID. ;-)

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @qAlexKo said in QButtonGroup difficulty:

          it can't set up the active button by a known ID

          buttonGroup->button(someId)->setChecked(true);
          

          (plus error checking).

          Pl45m4P 1 Reply Last reply
          1
          • JonBJ JonB

            @qAlexKo said in QButtonGroup difficulty:

            it can't set up the active button by a known ID

            buttonGroup->button(someId)->setChecked(true);
            

            (plus error checking).

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by
            #5

            @JonB said in QButtonGroup difficulty:

            buttonGroup(someId)->setChecked(true);

            btnGrp->button(someId)->setChecked(true);
            

            ;-)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            JonBJ Q 2 Replies Last reply
            0
            • Pl45m4P Pl45m4

              @JonB said in QButtonGroup difficulty:

              buttonGroup(someId)->setChecked(true);

              btnGrp->button(someId)->setChecked(true);
              

              ;-)

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Pl45m4 That was part of the "plus error checking" ;-) Corrected, thanks.

              1 Reply Last reply
              0
              • Pl45m4P Pl45m4

                @JonB said in QButtonGroup difficulty:

                buttonGroup(someId)->setChecked(true);

                btnGrp->button(someId)->setChecked(true);
                

                ;-)

                Q Offline
                Q Offline
                qAlexKo
                wrote on last edited by
                #7

                @Pl45m4 said in QButtonGroup difficulty:

                btnGrp->button(someId)->setChecked(true);

                Yeah! Nice!

                1 Reply Last reply
                0
                • Q qAlexKo has marked this topic as solved on

                • Login

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