Compare QRadioButtons
-
Yes, but how did you create the radio buttons? Did you Qt designer?
Otherwise please post the code creating the radio buttons.
-
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]
-
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.
-
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
-
if you have an array you can do as you have already suggested.
-
Hi Koahnig,
Thanks alot, can you write me an Example or How you mean?
Regards
-
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.
-
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]
-
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.? -
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 :-( .