How to pass the parameters between the SIGNAL and SLOTS
-
i'm sorry, i have a lot of classe , methode and line of code, and there is interaction between them with QTimer , Mathematique fonction ...etc , for this i can't to post all my code
-
hi
Seems to work fine even with a 100 MS timer so should work for you too.Can you please try ?
https://www.dropbox.com/s/l8go4t71unosl05/CrossTalk.zip?dl=0

-
@Alex42
The dropbox link is the full project you can just run.
If not allowed to use dropbox is there any other such service you are allowed to use ?
(you don't have to register. just press the download and you should get zip file) -
ok, ok ,
when I try it all alone, (with only the QTimer ) it works very well, (like your exemple )
but when i try my real interface it does not workyou know ?
my first QlineEdit (1 forme ) containe the result of the calculaions (which makes calculates each 1000ms) whithe this fonction ```i show you how the calcualte_3() fonction do
void Mesure :: calculate_3 () { S++; if (S>0) { emit newtextChanged_1(mence->text()); /// works double Val13=ui->lineEdit_13->text().toInt(); double Val14=ui->lineEdit_14->text().toInt(); double Val15=ui->lineEdit_15->text().toInt(); double Val16=ui->lineEdit_16->text().toInt(); double V1,V2, V3 ,V4, V5, V6,V7; int P=ui->spinBox_1->value(); switch (P) { case 2 : if ( Val0 <Val1) { ui->lineEdit_17->setText(QString::number(Val9)); // mence->setText(QString::number(Val9)); } 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)); // mence->setText(QString::number(V1)); } break; case 3: if ( ((Val0>Val2) && (Val0<Val3))|| (Val0>Val3) ) { V2 = Val11 * (Val0 - Val2)/(Val3-Val2) +Val10 *(Val3-Val0)/(Val3-Val2); //V2 = Val12 * (Val0-Val2/Val3-Val2) + Val10 * (Val3-Val0/Val3-Val2); ui->lineEdit_17->setText(QString::number(V2)); //mence->setText(QString::number(V2)); } else if (Val0<Val2) { V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1); ui->lineEdit_17->setText(QString::number(V1)); // mence->setText(QString::number(V1)); } break; /* else if (Val0>Val1 && Val0 <Val2 &&Val0 < Val3 ) { // V3 = (Val10 * (Val3-Val0) - Val11 * (Val2-Val0))/(Val3-Val2); //ui->lineEdit_17->setText(QString::number(V3)); V1 = Val0* Val10/Val2; ui->lineEdit_17->setText(QString::number(V1)); } else if ( Val0 > Val3) { V4= ((Val0 - Val2)* Val11 - Val10 * (Val0-Val3))/ (Val3-Val2) ; ui->lineEdit_17->setText(QString::number(V4)); } */ break; case 4 : if (((Val0 > Val3) && (Val0 <Val4) )||(Val0>Val4)) { V3 = Val12 * (Val0-Val3)/(Val4-Val3) +Val11 * (Val4-Val0)/(Val4-Val3); ui->lineEdit_17->setText(QString::number(V3)); // mence->setText(QString::number(V3)); } else if ((Val0>Val2) && (Val0 <Val3))and this fonction is update withe the Qtimer lik this connectionconnect (timer, SIGNAL (timeout()), this ,SLOT (calculate_3()));
-
ok, ok ,
when I try it all alone, (with only the QTimer ) it works very well, (like your exemple )
but when i try my real interface it does not workyou know ?
my first QlineEdit (1 forme ) containe the result of the calculaions (which makes calculates each 1000ms) whithe this fonction ```i show you how the calcualte_3() fonction do
void Mesure :: calculate_3 () { S++; if (S>0) { emit newtextChanged_1(mence->text()); /// works double Val13=ui->lineEdit_13->text().toInt(); double Val14=ui->lineEdit_14->text().toInt(); double Val15=ui->lineEdit_15->text().toInt(); double Val16=ui->lineEdit_16->text().toInt(); double V1,V2, V3 ,V4, V5, V6,V7; int P=ui->spinBox_1->value(); switch (P) { case 2 : if ( Val0 <Val1) { ui->lineEdit_17->setText(QString::number(Val9)); // mence->setText(QString::number(Val9)); } 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)); // mence->setText(QString::number(V1)); } break; case 3: if ( ((Val0>Val2) && (Val0<Val3))|| (Val0>Val3) ) { V2 = Val11 * (Val0 - Val2)/(Val3-Val2) +Val10 *(Val3-Val0)/(Val3-Val2); //V2 = Val12 * (Val0-Val2/Val3-Val2) + Val10 * (Val3-Val0/Val3-Val2); ui->lineEdit_17->setText(QString::number(V2)); //mence->setText(QString::number(V2)); } else if (Val0<Val2) { V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1); ui->lineEdit_17->setText(QString::number(V1)); // mence->setText(QString::number(V1)); } break; /* else if (Val0>Val1 && Val0 <Val2 &&Val0 < Val3 ) { // V3 = (Val10 * (Val3-Val0) - Val11 * (Val2-Val0))/(Val3-Val2); //ui->lineEdit_17->setText(QString::number(V3)); V1 = Val0* Val10/Val2; ui->lineEdit_17->setText(QString::number(V1)); } else if ( Val0 > Val3) { V4= ((Val0 - Val2)* Val11 - Val10 * (Val0-Val3))/ (Val3-Val2) ; ui->lineEdit_17->setText(QString::number(V4)); } */ break; case 4 : if (((Val0 > Val3) && (Val0 <Val4) )||(Val0>Val4)) { V3 = Val12 * (Val0-Val3)/(Val4-Val3) +Val11 * (Val4-Val0)/(Val4-Val3); ui->lineEdit_17->setText(QString::number(V3)); // mence->setText(QString::number(V3)); } else if ((Val0>Val2) && (Val0 <Val3))and this fonction is update withe the Qtimer lik this connectionconnect (timer, SIGNAL (timeout()), this ,SLOT (calculate_3()));
Hi
In the code you shown, you call
emit newtextChanged_1(mence->text());
in the top and that seems to work.But I don't see you call
emit after any of the calculations?It will send a copy of the text so you have to do it after you have put it into mence->setText.
so if you don't have it, you need the emit to be at the end of the function.
-
@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) ) ));;