Custom QDialog ... event filter in a different thread warning
-
/**************************** main windows ****************/ void MainWindow::PcProblemMessage(int PcNumber) { if(firstTimeTestPc){ m_Dia3 = new Cdia3(this); /**** I try without in these manner : new Cdia3(); too but not success ***/ // m_Dia3->setModal(true); m_Dia3->setWindowTitle("Pc Error Advice"); //m_Dia3->setAttribute(Qt::WA_DeleteOnClose, true); m_Dia3->setWindowFlags(Qt::WindowStaysOnTopHint); // m_Dia3->setAttribute(Qt::WA_NoSystemBackground, false); // m_Dia3->setAttribute(Qt::WA_TranslucentBackground, false); m_Dia3->SetValueChanged(PcNumber); m_Dia3->show(); } } /********************** Cdia3 class *********************/ Cdia3::Cdia3(QWidget *parent) : QDialog(parent), ui(new Ui::Cdia3) { ui->setupUi(this); this->setWindowFlags(Qt::WindowStaysOnTopHint); QRect scr = QApplication::desktop()->screenGeometry(); this->move(( scr.center() - rect().center() )); connect(ui->bmh3_CloseButton1, SIGNAL(pressed()), this, SLOT(close())); } /*********** the warning when hovering on Dialog with mouse ************/ QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread. QApplication: Object event filter cannot be in a different thread.
Rarely use QDialod subclass ... but these one work from 3 mounth without warning ... today (after change the QDialog Start/show system of calling ... the logic that call my QDialog void...) appear these annoing warning .... is referring the at mouse when it over the QDialog .... is a Z level problem??
I have some doubt because my mainwindows it have the same whindows flags of QDialog + w.setAttribute(Qt::WA_AcceptTouchEvents); .....
P.S. my dialog as you can see show only a fixed label + a int value ... these work perfect but close button not work because these warning ....
regards
Giorgio -
Hi,
From where is that function called ?
-
@SGaist is called from mainwindows .... when a user press a button the button call a void. When these last void return an appropriate signal a "connect signal slot" mechanism call PcProblemMessage(int PcNumber) ..... is quite simple ... no other strange connection with other thread ..
sorry not so real .....
regards
giorgio -
@SGaist I'm a lair ..... I realize that the previous info is not so real. There are not button that call my PcProblemMessages .... there is these row:
connect(mThread4, SIGNAL(Onpc(bool, int)), this, SLOT(ComunicateOnOffPc(bool, int)), Qt::DirectConnection);
So who calls the function is void mainwindows::ComunicateOnOffPc that if bool var is false call PcProblemMessage(int) ... is true make other operation.
So these is the problem?? There are a way to play around with success & elegant way?? (for shure I can make a global var with bool result & int number when it change send signal pcstatesignaLIschanged connect these signal with PcProblemMessages ... but not shure these solve and then there is to be said that it is not a good piece of code ... but it seems just a jumble for babies )
regards
Giorgio -
@gfxx jumble for babe code works ... but is possible realize something whitouth calling other signal on mainwindows?
(code that partially solve the question...)
connect(this, SIGNAL(jumbleForBabePcState(int)), this, SLOT(PcProblemMessage(int)), Qt::QueuedConnection);
this is calling from:
SLOT(ComunicateOnOffPc(bool, int))
all in mainwindows.... so thread call a mainwindows SLOT that emit SIGNAL jumble that call void PcProblemMessage ...
regards
giorgio -
Can you show your actual code ? It's not really clear from your description.
-
@SGaist actually...
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /******* some stupid code **********/ connect(mThread4, SIGNAL(Onpc(bool, int)), this, SLOT(ComunicateOnOffPc(bool, int)), Qt::DirectConnection); connect(this, SIGNAL(jumbleForBabePcState(int)), this, SLOT(PcProblemMessage(int)), Qt::QueuedConnection); /********* other code**********/ } void Mainwindows::ComunicateOnOffPc( bool bol, int it) { /********** bla bla *********/ emit jumbleForBabePcState(it); } void MainWindow::PcProblemMessage(int PcNumber) { if(firstTimeTestPc){ m_Dia3 = new Cdia3(this); /**** I try without in these manner : new Cdia3(); too but not success ***/ // m_Dia3->setModal(true); m_Dia3->setWindowTitle("Pc Error Advice"); //m_Dia3->setAttribute(Qt::WA_DeleteOnClose, true); m_Dia3->setWindowFlags(Qt::WindowStaysOnTopHint); // m_Dia3->setAttribute(Qt::WA_NoSystemBackground, false); // m_Dia3->setAttribute(Qt::WA_TranslucentBackground, false); m_Dia3->SetValueChanged(PcNumber); m_Dia3->show(); } }
giorgio
-
@gfxx said in Custom QDialog ... event filter in a different thread warning:
connect(mThread4, SIGNAL(Onpc(bool, int)), this, SLOT(ComunicateOnOffPc(bool, int)), Qt::DirectConnection);
You have specified a
DirectConnection
. This meansMainWindow::ComunicateOnOffPc()
will run in the thread that emits theOnpc()
signal.Why do you want a
DirectConnection
? Try using aQueuedConnection
orAutoConnection
instead.