How to pass the parameters between the SIGNAL and SLOTS
-
@Alex42 said in How to pass the parameters between the SIGNAL and SLOTS:
i will try to emit the signal every time i do a calculation in this fonction
i'm trying to emit the signal every time i do a calculation in this fonction but without success
case 2 : if ( Val0 <Val1) { ui->lineEdit_17->setText(QString::number(Val9)); mence->setText(QString::number(Val9)); emit newtextChanged_1(mence->text()); } else if ( ((Val0>Val1) && (Val0<Val2)) || (Val0>2)) { // V1 = Val0* Val10/Val2; V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1); ui->lineEdit_17->setText(QString::number(V1)); emit newtextChanged_1(mence->text()); mence->setText(QString::number(V1)); } -
incredible , when i try this he work very will
void Mesure :: calculate_3 () { S++; emit newtextChanged_1(QString::number (S)); }but withe this signal he want to work
emit newtextChanged_1(mence ->text());Ok.
I was wondering one thing.
All your other linedits are in the UI
but mence
is notDo you have 2 of them for some reason ?
so there is also the
ui->mence ?Why is mence not in the UI.
Do you insert it from code to the fom? -
the ui->lineEdit_17->text() ,and mence ->text() , it's the same thing , just one coded with a hand , and auther coder with Qt creator Form (Ui)
@Alex42
I'm sure, that if you do:void Mesure :: calculate_3 () { S++; mence->setText(QString::number (S)); emit newtextChanged_1(mence->text()); }it will work just as well as
void Mesure :: calculate_3 () { S++; emit newtextChanged_1(QString::number (S)); }somewhere you're setting your mence->text to 0
I good point to start the debugger and step through your code line by line, btw.
-
@J-Hilk , thank you for your response , yes i don't any probleme with your code ( it works very will )
but the probleme it's when i try to transmete the real values ,
are you understande that the real valueu it's not number S ?@Alex42 said in How to pass the parameters between the SIGNAL and SLOTS:
are you understande that the real valueu it's not number S ?
I do, do you realise, that mence is not the problem here ?
on a hinge: try the following:
//V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1); mence->setText(QString::number( ( Val10 * (Val0 - Val1)/static_cast<double>(Val2-Val1) +Val9 *(Val2-Val0)/static_cast<double>(Val2-Val1) ) ));; -
@J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:
//V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1);
mence->setText(QString::number( ( Val10 * (Val0 - Val1)/static_cast<double>(Val2-Val1) +Val9 *(Val2-Val0)/static_cast<double>(Val2-Val1) ) ));;it's the same problem
-
you know in the same classe i don't have any problem , just when i try to read the values in another class, for exemple
when i do this in the same classe i have no problemeconnect (ui->lineEdit_17, SIGNAL (textChanged(QString)), this ,SLOT (encore_2(QString))); void mesure::encore_2(QString) { mence->setText(ui->lineEdit_17->text()); -
@J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:
somewhere you're setting your mence->text to 0
it can be a private or public story because I declared my variables inside the calculate () slot
-
@J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:
somewhere you're setting your mence->text to 0
it can be a private or public story because I declared my variables inside the calculate () slot
Go to where you define mence and right click and use "Find Usage" and it will show all places.
I cannot guess what it only send zero but we know signal works and we can send a string
so its a logical bug with mence and we cannot not spot it as we see only pieces and its easy to stare blind on own code so you dont either. -
@mrjj said in How to pass the parameters between the SIGNAL and SLOTS:
so its a logical bug with mence and we cannot not spot it as we see only pieces and its easy to stare blind on own code so you dont either.
@ mrjj, @J.Hilk, thank you for your help, so i will try to change my logic of coded, and i will take you know of the evolution