Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom QDialog ... event filter in a different thread warning
Forum Updated to NodeBB v4.3 + New Features

Custom QDialog ... event filter in a different thread warning

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 3.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by gfxx
    #1
    /**************************** 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

    bkt

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From where is that function called ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      gfxxG 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        From where is that function called ?

        gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by gfxx
        #3

        @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

        bkt

        gfxxG 1 Reply Last reply
        0
        • gfxxG gfxx

          @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

          gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by gfxx
          #4

          @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

          bkt

          gfxxG 1 Reply Last reply
          0
          • gfxxG gfxx

            @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

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by gfxx
            #5

            @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

            bkt

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you show your actual code ? It's not really clear from your description.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              gfxxG 1 Reply Last reply
              0
              • SGaistS SGaist

                Can you show your actual code ? It's not really clear from your description.

                gfxxG Offline
                gfxxG Offline
                gfxx
                wrote on last edited by gfxx
                #7

                @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

                bkt

                JKSHJ 1 Reply Last reply
                0
                • gfxxG gfxx

                  @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

                  JKSHJ Online
                  JKSHJ Online
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  @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 means MainWindow::ComunicateOnOffPc() will run in the thread that emits the Onpc() signal.

                  Why do you want a DirectConnection? Try using a QueuedConnection or AutoConnection instead.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  gfxxG 1 Reply Last reply
                  2
                  • JKSHJ JKSH

                    @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 means MainWindow::ComunicateOnOffPc() will run in the thread that emits the Onpc() signal.

                    Why do you want a DirectConnection? Try using a QueuedConnection or AutoConnection instead.

                    gfxxG Offline
                    gfxxG Offline
                    gfxx
                    wrote on last edited by
                    #9

                    @JKSH Thanks ... I Ignore these...(This means MainWindow::ComunicateOnOffPc() will run in the thread that emits the Onpc() signal.) I thinks is only buffer/unbuffer related flag..

                    regards
                    Giorgio

                    bkt

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved