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] How to get selected radio button value?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to get selected radio button value?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 23.8k 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 18 Jun 2014, 09:07 last edited by
    #1

    Hi, I have a form with many radio buttons like this

    http://tinypic.com/view.php?pic=mkeyqt&s=8#.U6FVbPmSwms

    I want to get the value of radio button for each line so I tried out the easy way of printing the value of the selected radio button for let's say Interconnect Enabled.

    @
    QString ru_interconnect;

    if (ui->radioButton_22->isChecked()) //selection is Yes
    {

        ru_interconnect = "Y";
        qDebug() << "Interconnect Yes is checked" << ru_interconnect;
    } else if (ui->radioButton_23->isChecked()) // selection is No
    {
    
        ru_interconnect = "N";
         qDebug() << "Interconnect No is checked" << ru_interconnect;
    }
    

    @

    I link it to a push button so that upon clicking the button, the value will be displayed. No results was shown in the compilation box. The Yes/No buttons on each line are grouped.
    I did the same for lineedit and the values can be printed. Any idea on how to solve this?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jeroentjehome
      wrote on 18 Jun 2014, 10:06 last edited by
      #2

      Hi,
      A bit more code needed. How did you link the 'ru_interconnect' to a pushbutton? Do you use signal/slots?

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sharon_obl82
        wrote on 18 Jun 2014, 10:15 last edited by
        #3

        From the push button. I just go to slot via clicked event. I code this in the clicked function.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jeroentjehome
          wrote on 18 Jun 2014, 10:37 last edited by
          #4

          Yes, so, the push button emits a clicked signal, you did connect it to a slot to print the text? What does your debugger do? Does it reach the pushbutton clicked slot? In your output pane you could see if the connection had errors and the signal/slot is not setup properly.
          And when you click the puchbutton what should happen then? Display the text where?

          Greetz, Jeroen

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TheBadger
            wrote on 18 Jun 2014, 11:19 last edited by
            #5

            Not sure why this is not working but we have a rule to name GUI controls that you need to refer to in the code, thus radioButton_22 is not acceptable and should be something like radioButton_Interconnect_Yes and the other radioButton_Interconnect_No. Then at least from the code you can see if you refer to the correct radio button without having to go to the designer and find 22...

            So my assumption is that you are actually referring to the correct radio buttons. Then I have no idea why it is not working, it is supposed to.


            Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sharon_obl82
              wrote on 19 Jun 2014, 08:25 last edited by
              #6

              Thanks all,
              It's working now. I renamed the buttons to radioButton_22_Yes etc in the if else statement, took out the connect signal and slots and it worked.

              1 Reply Last reply
              0

              1/6

              18 Jun 2014, 09:07

              • Login

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