How to pass the parameters between the SIGNAL and SLOTS
-
Hello every one , I have two interface 2 (.cpp,.h,.ui) that have every one the QLineEdite that change every 100 s and I want to transmmet the values bettween this two interface
For this I created the signale in the firste interface and the slot in the secande interface,
Now I can to transmet the values of QLCD Numer from the firste interface to the second interface , but I can't to transmete the values of a QLineEdite from the firste interface to the second interface
My question it’s how to transmete values of QLineEdite in real Time between two interface
Thank you in advancecode first interface
.Hpublic slots: void encore_2(QString); signals: void newtextChanged_1(QString t);.cpp
void Mesure::encore_2(QString) { mence->setText(ui->Anale_1->text()); } void Mesure :: calculate_3 () { S++; if (S>0) { emit newtextChanged_1(QString::number (ui->lcdNumber_1->value())); //emit newtextChanged_1(QString::number (S)); // emit newtextChanged_1(mence->text()); }.Seconde interface
.hvoid encore_2(QString t); Mesure get;.cpp
connect(&get,SIGNAL(newtextChanged_1(QString)),this,SLOT(encore_2(QString))); void Mesureone::encore_2(QString t) { mence_one->setText(t); } -
Hi
Do you have Q_OBJECT in both classes ?Check if the connect returns true
qDebug() << "mysignal:" << connect(&get,SIGNAL(newtextChanged_1(QString)),this,SLOT(encore_2(QString)));
-
@mrjj thank you for your response, ,, yes i have the Q_object in the bothe classes
But When i try to test this code i have an error " no matching member function for call to "connect "@Alex42
Hi
But is the
connect function not inside a class function?If not call it like
QObject::connect( ....
and you cannot use "this" but must use a pointer to the instance.
connect(&get,SIGNAL(newtextChanged_1(QString)),this,SLOT(encore_2(QString)));
If its not inside class, there is no this.
So please show the code around the connect.
-
@Alex42 said in How to pass the parameters between the SIGNAL and SLOTS:
no matching member function for call to "connect "
ok , ok , I Made a Mistake
ignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: truemysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true
mysignal: true -
for more information , i created the principle interface (MainWindow), and in this interface i have two QPushbutton ,the first button open the firste interface (Mesure) , and the second Button open the seconde interface
- i don't get any messages about the connect failing
-( i can to change the data between the firste interface (Mesure) and the seconde interface (Mesureone ), but with the QLineEdit i can't to transmite data between this interfaces - i used the debugger , and the slot is called and the connect executed . But i can't to interact between this interfaces with the QLineEdit (incredible)
- i don't get any messages about the connect failing
-
for more information , i created the principle interface (MainWindow), and in this interface i have two QPushbutton ,the first button open the firste interface (Mesure) , and the second Button open the seconde interface
- i don't get any messages about the connect failing
-( i can to change the data between the firste interface (Mesure) and the seconde interface (Mesureone ), but with the QLineEdit i can't to transmite data between this interfaces - i used the debugger , and the slot is called and the connect executed . But i can't to interact between this interfaces with the QLineEdit (incredible)
Hi
Your connect seems to be called many times.
Normally you should only call it once as it will send multiple times if you connect multiple times and
that is normally not what you want.Anyway,
Are you saying that
void Mesure :: calculate_3 () { S++; if (S>0) { emit newtextChanged_1(QString::number (ui->lcdNumber_1->value())); /// works but emit newtextChanged_1(mence->text()); // wont work ? - i don't get any messages about the connect failing
-
@mrjj said in How to pass the parameters between the SIGNAL and SLOTS:
Your connect seems to be called many times.
there is no probleme if you call it many time or you call it once , i tried many situation ( call it once , and call it many time ) but that not work
-
@mrjj said in How to pass the parameters between the SIGNAL and SLOTS:
emit newtextChanged_1(mence->text()); // wont work ?
emit newtextChanged_1(mence->text()); // wont work ? exactly what i whant to do buthe d'ont work
-
Ok that is a bit o.O
so try
QString text = mence->text();
qDebug() << "sending:" << text;
emit ewtextChanged_1(text);and see if the mence is the one you think it is as that is my only guess then as
the signal clearly works :)Yes, I understand you change the text of the lineEdit every sec,but that should not matter
as we just get what ever was set last when we ask. -
yes exactly what i want , befor i tried this and works very well ,
but the probleme is in the second interface i can't receve this data 
( in the seconde interface i receve only 0( the fiste values) , i can't receive the values when is chenged -
yes exactly what i want , befor i tried this and works very well ,
but the probleme is in the second interface i can't receve this data 
( in the seconde interface i receve only 0( the fiste values) , i can't receive the values when is chengedSo in interface 2, you only see the "0" and never "12222" etc ?
But you could send "hello" and other string ?
That I cant explain. seems impossible.Just so I understand.
You have a main window and 2 buttons. Each button opens a new Form/window and
form1 has a timer or something that makes a lineEdit count/set some value.
This value you try to emit to form2 when calculate_3 is called ? -
@mrjj said in How to pass the parameters between the SIGNAL and SLOTS:
So in interface 2, you only see the "0" and never "12222" etc ?
So in interface 2, you only see the "0" and never "12222" etc ? yes exactly
But you could send "hello" and other string ? yes i can send hello
You have a main window and 2 buttons. Each button opens a new Form/window and
form1 has a timer or something that makes a lineEdit count/set some value.
This value you try to emit to form2 when calculate_3 is called ? exactly what i want to do -
@mrjj said in How to pass the parameters between the SIGNAL and SLOTS:
So in interface 2, you only see the "0" and never "12222" etc ?
So in interface 2, you only see the "0" and never "12222" etc ? yes exactly
But you could send "hello" and other string ? yes i can send hello
You have a main window and 2 buttons. Each button opens a new Form/window and
form1 has a timer or something that makes a lineEdit count/set some value.
This value you try to emit to form2 when calculate_3 is called ? exactly what i want to do