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. [SOLVED]Radio button question
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Radio button question

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k 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.
  • S Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

    Hi,

    I have a form designed using Qt Designer as shown here.

    http://i60.tinypic.com/2wrkvgk.jpg

    I group the radio buttons horizontally first and I could select one radio button for every line even after grouping them all together in grid layout.

    But at run time, this happens:

    http://tinypic.com/view.php?pic=20u7qz5&s=8#.U5ajKPmSwms

    Only one radio button can be selected out of all. What I did was to put them in scroll area (because my form is really long) and i have no choice but to group them in a layout. Why is there difference when i design it in Qt Designer and unselectable radio buttons at runtime? And what can i do so that the radio buttons at each line can be selected?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You need to turn off "autoExclusive":http://qt-project.org/doc/qt-5/qabstractbutton.html#autoExclusive-prop option.

      Please note, however, that the general consensus is that check boxes should be used when many can be selected at once. Radio buttons are meant to be used when only one can be selected.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sharon_obl82
        wrote on last edited by
        #3

        Hi sierdzio,

        Is this the right way to do it?

        @
        QButtonGroup bg;
        bg.addButton(ui->radioButton);
        ui->radioButton->setChecked(true);
        ui->radioButton->autoExclusive(false);
        @

        I get the compilation error:
        no matching function for call to "QRadioButton::autoExclusive(bool);

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          All property setters in Qt begin with "set":
          @
          ui->radioButton->setAutoExclusive(false);
          @

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sharon_obl82
            wrote on last edited by
            #5

            Oh my bad, thanks very much, it works now.

            1 Reply Last reply
            0

            • Login

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