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. Compare QRadioButtons

Compare QRadioButtons

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 4.9k 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
    samlion007
    wrote on last edited by
    #1

    Hi every body,

    I have a Problem,

    How it works?
    I want to add more then 100 RadioButton ,it is not a Problem, my Problem was how i can put them on For loop to check them if they selected or not.

    e.g :

    @
    QSTring result;

    For( int i=0; i <100 ; i++)
    {
    result[i] =compare1(radiobuttom_A[i],radiobuttom_C[i]);

    }
    @

    waht i did, it is: // compare1(Qradiobuttom ,QradioButtom)

    @
    s4_4+=Compare1(ui->A1 , ui->C1 )
    s4_5+=Compare1(ui->A2 , ui->C2 )
    s4_6+=Compare1(ui->A3 , ui->C3)
    s4_7+=Compare1(ui->A4 , ui->C4 )
    s4_8+=Compare1(ui->A5 , ui->C5)
    s4_9+=Compare1(ui->A6 , ui->C6 )
    s4_10+=Compare1(ui->A7 , ui->C7)
    s4_11+=Compare1(ui->A8 , ui->C8 )
    s4_12+=Compare1(ui->A9 , ui->C9 )
    s4_13+=Compare1(ui->A10 , ui->C10 )
    s4_14+=Compare1(ui->A11 , ui->C11 )
    s4_15+=Compare1(ui->A12 , ui->C12 )
    s4_16+=Compare1(ui->A13 , ui->C13 )
    s4_17+=Compare1(ui->A14 , ui->C14 )
    s4_18+=Compare1(ui->A15 , ui->C15)
    s4_19+=Compare1(ui->A16 , ui->C16 )
    s4_20+=Compare1(ui->A17 , ui->C17 )
    s4_21+=Compare1(ui->A18 , ui->C18)
    s4_22+=Compare1(ui->A19 , ui->C19)
    s4_23+=Compare1(ui->A20 , ui->C20 )
    s4_24+=Compare1(ui->A21 , ui->C21 )
    s4_25+=Compare1(ui->A22 , ui->C22 )
    s4_26+=Compare1(ui->A23 , ui->C23 )
    s4_27+=Compare1(ui->A24 , ui->C24 )
    s4_28+=Compare1(ui->A25 , ui->C25 )@

    Best Regards

    EDIT: did the split of, Gerolf

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      You should start a new thread when you have a new question.

      How did you create your 100 radio buttons? Have you used Qt designer?

      Vote the answer(s) that helped you to solve your issue(s)

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

        Hi,

        First thank you so much for quick answer,
        sorry about the thread,i am new here

        can you plaese see this Photo:

        http://www.pic-upload.de/view-12705054/test.jpg.html

        If you see ,there is about 2 * 25 lines with Radiobuttons ,
        i want to test each Line , so how i can make the test on for loop ?
        Like :

        @
        For( int i=0; i <100 ; i++)
        { result[i] =compare1(radiobuttom_A[i],radiobuttom_C[i]);
        }
        @

        compare1 is a function , which check if A or C is checked.

        Regards

        [EDIT: code formatting, please wrap in @-tags, Volker]

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Yes, but how did you create the radio buttons? Did you Qt designer?

          Otherwise please post the code creating the radio buttons.

          Vote the answer(s) that helped you to solve your issue(s)

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

            HI,

            I used Qt designer,I am beginner on Qt ,so i am not good Qt designer.
            There is no code for creating the RadioButtons, i created them with Qt designer.

            the Programm it works good,just want to change the code ,
            instead of :
            @s4_4+=Compare1(ui->A1 , ui->C1 )
            s4_5+=Compare1(ui->A2 , ui->C2 )
            s4_6+=Compare1(ui->A3 , ui->C3)
            s4_7+=Compare1(ui->A4 , ui->C4 )
            s4_8+=Compare1(ui->A5 , ui->C5)
            s4_9+=Compare1(ui->A6 , ui->C6 )
            s4_10+=Compare1(ui->A7 , ui->C7)
            s4_11+=Compare1(ui->A8 , ui->C8 )
            s4_12+=Compare1(ui->A9 , ui->C9 )
            s4_13+=Compare1(ui->A10 , ui->C10 )
            s4_14+=Compare1(ui->A11 , ui->C11 )
            s4_15+=Compare1(ui->A12 , ui->C12 )
            s4_16+=Compare1(ui->A13 , ui->C13 )
            s4_17+=Compare1(ui->A14 , ui->C14 )
            s4_18+=Compare1(ui->A15 , ui->C15)
            s4_19+=Compare1(ui->A16 , ui->C16 )
            s4_20+=Compare1(ui->A17 , ui->C17 )
            s4_21+=Compare1(ui->A18 , ui->C18)
            s4_22+=Compare1(ui->A19 , ui->C19)
            s4_23+=Compare1(ui->A20 , ui->C20 )
            s4_24+=Compare1(ui->A21 , ui->C21 )
            s4_25+=Compare1(ui->A22 , ui->C22 )
            s4_26+=Compare1(ui->A23 , ui->C23 )
            s4_27+=Compare1(ui->A24 , ui->C24 )
            s4_28+=Compare1(ui->A25 , ui->C25 )@

            only the for loop like:

            @
            For( int i=0; i <100 ; i++)
            { result[i] =compare1(radiobuttom_A[i],radiobuttom_C[i]);
            }
            @

            and sorry about my English, my English is bad

            Regards

            [EDIT: code formatting, please wrap in @-tags, Volker]

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              If the buttons are created by designer, you have to craete an additional array (or several arrays) and fill in the pointers there. Then you have array access. If you build them by hand, directlky put the pointers into arrays.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                samlion007
                wrote on last edited by
                #7

                Hi Gerolf,

                Thanks for Answer, i did what you said, it was ok, but i want to put the on FOR LOOP, is it Possib.?

                Regards

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  if you have an array you can do as you have already suggested.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    samlion007
                    wrote on last edited by
                    #9

                    Hi Koahnig,

                    Thanks alot, can you write me an Example or How you mean?

                    Regards

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      That would be the simplist case, I guess
                      @
                      QRadioButton radiobutton_A[100], radiobutton_C[100];
                      bool reults[100];

                      ...

                      for( int i=0; i <100 ; ++i)
                      {
                      result[i] =compare1(radiobuttom_A[i],radiobuttom_C[i]);
                      }
                      @

                      Better would be probably to use one of the containers e.g. QVector.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        samlion007
                        wrote on last edited by
                        #11

                        HI,

                        It did not worke ,What you think if i do:

                        @
                        QString Radio_name_A ="ui->A";
                        QString Radio_name_C ="ui->C";
                        QString Radio_A;
                        QString Radio_C;

                        for(int i=0; i<50;++i)
                        {
                        Radio_A=Radio_name_A + QString().number(i);
                        Radio_C=Radio_name_C + QString().number(i);
                        result=comare1(Radio_A,Radio_C);
                        }
                        @

                        Is it Posb.?

                        [EDIT: code formatting, please wrap in @-tags, Volker]

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          samlion007
                          wrote on last edited by
                          #12

                          HI,
                          It did not worke ,What you think if i do:
                          @QString Radio_name_A =“ui->A”;
                          QString Radio_name_C =“ui->C”;
                          QString Radio_A;
                          QString Radio_C;
                          for(int i=0; i<50;++i)
                          { Radio_A=Radio_name_A + QString().number(i); Radio_C=Radio_name_C + QString().number(i); result=comare1(Radio_A,Radio_C);
                          }@
                          Is it Posb.?

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            koahnig
                            wrote on last edited by
                            #13

                            Neither of your suggestion do work.
                            I can provide you only some little examples. The rest you have to do yourself. By the way how much C++ experience do you have ?
                            When you have created your radio button with the creator as write above, there is some major change required. Be careful to do changes to the files automatically generated from the designer files. Those changes are lost quite fast during the next build. You would not be the first one running into such problems :-( .

                            Vote the answer(s) that helped you to solve your issue(s)

                            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