ok, this is my code:
main thread:
// function for button start
void mainThread::clickedStart(){
obj2 = new seconThread(params);
connect( obj2 , SIGNAL( update1( int, int ) ), SLOT( onUpdate1( int, int ) ) );
connect( obj2 , SIGNAL( update2( int, int ) ), SLOT( onUpdate2( int, int ) ) );
obj2 ->start();
}
// slot update1
void mainThread::onUpdate1(int a, int b){
ui.
showtrace1->setText
(QString("%1").
arg(a
));
ui.
showtrace2->setText
(QString("%1").
arg(b
));
}
// slot update2
void mainThread::onUpdate2(int a, int b){
ui.
showtrace3>setText
(QString("%1").
arg(a
));
ui.
showtrace4->setText
(QString("%1").
arg(b
));
}
// function for button start
void mainThread::clickedStart(){
obj2 = new seconThread(params);
connect( obj2 , SIGNAL( update1( int, int ) ), SLOT( onUpdate1( int, int ) ) );
connect( obj2 , SIGNAL( update2( int, int ) ), SLOT( onUpdate2( int, int ) ) );
obj2 ->start();
}
// slot update1
void mainThread::onUpdate1(int a, int b){
ui.showtrace1->setText(QString("%1").arg(a));
ui.showtrace2->setText(QString("%1").arg(b));
}
// slot update2
void mainThread::onUpdate2(int a, int b){
ui.showtrace3>setText(QString("%1").arg(a));
ui.showtrace4->setText(QString("%1").arg(b));
}
To copy to clipboard, switch view to plain text mode
second thread:
void seconThread::run(){
obj3 = new thirdThread(params);
connect( obj3 , SIGNAL( update3(int, int) ), SIGNAL(update1 (int, int) ) );
connect( obj3 , SIGNAL( update4(int, int) ), SIGNAL( update2(int, int) ) );
obj3 ->start();
}
void seconThread::run(){
obj3 = new thirdThread(params);
connect( obj3 , SIGNAL( update3(int, int) ), SIGNAL(update1 (int, int) ) );
connect( obj3 , SIGNAL( update4(int, int) ), SIGNAL( update2(int, int) ) );
obj3 ->start();
}
To copy to clipboard, switch view to plain text mode
third thread:
void thirdThread::run(){
while(control){
// some prrcess
emit update3( a, b);
emit update4( c, d);
}
}
void thirdThread::run(){
while(control){
// some prrcess
emit update3( a, b);
emit update4( c, d);
}
}
To copy to clipboard, switch view to plain text mode
The point is, I can't get the signals update1 and update2, I've tried this way (connect signal to signal in the second thread)and to send a signal from thread3 to thread2 in a slot and then to send a signal from this to the main thread but it didn't work.
P.S. I tried to make the connection queued too, but no luck!!
Thanks in advance!!
Bookmarks