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. Add text when selecting radiobutton
QtWS25 Last Chance

Add text when selecting radiobutton

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 958 Views
  • 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.
  • F Offline
    F Offline
    fender
    wrote on last edited by
    #1

    When you select a specific radiobutton, you need to add text to the already existing one. Ie in the group box is 60, then 60 is added, if 40 is selected, then 40. How to do it correctly? Now my current text is deleted and replaced, but not added.
    An example of how it should be
    0_1529472305264_цукцукцук.PNG

    jsulmJ 1 Reply Last reply
    0
    • Prince_0912P Offline
      Prince_0912P Offline
      Prince_0912
      wrote on last edited by Prince_0912
      #2

      Hi @fender ,
      You have to first check that radio button is checked or not for this,

      if( ui->radio_button->isChecked())
      {
      ui->lineEdit->setText(ui->radio_button->text());
      }
      code inside if condition is set the value of radio button( in your case 40 ,60 etc.) in lineEdit.
      This code help you.

      1 Reply Last reply
      0
      • F fender

        When you select a specific radiobutton, you need to add text to the already existing one. Ie in the group box is 60, then 60 is added, if 40 is selected, then 40. How to do it correctly? Now my current text is deleted and replaced, but not added.
        An example of how it should be
        0_1529472305264_цукцукцук.PNG

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @fender To append to the string

        ui->lineEdit->setText(ui->lineEdit->text() + ui->radio_button->text());
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Is that a good strategy adding the radios text ?
          How will you handle if user changes his mind and goes from 30 to 60 in group 2 ?
          However, if you construct the full string each time, it will work.
          Just wondering :)

          Prince_0912P 1 Reply Last reply
          3
          • mrjjM mrjj

            Hi
            Is that a good strategy adding the radios text ?
            How will you handle if user changes his mind and goes from 30 to 60 in group 2 ?
            However, if you construct the full string each time, it will work.
            Just wondering :)

            Prince_0912P Offline
            Prince_0912P Offline
            Prince_0912
            wrote on last edited by
            #5

            @mrjj Yes you are right!!!!
            Whenever user changes radiobutton checked event then text is appending everytime cause of concatenation in lineEdit. Therefore button text is as it is everytime.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Then re-build the full string when any of these widgets change and replace the whole text.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3

              • Login

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