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. QDialog Trasparent after close event loose touch tap event
Forum Updated to NodeBB v4.3 + New Features

QDialog Trasparent after close event loose touch tap event

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 774 Views 1 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
    #1

    my QDialog subclass :

    #include "help.h"
    #include "ui_help.h"
    
    help::help(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::help)
    {
        ui->setupUi(this);
    
        this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
        QScreen *screen = QGuiApplication::primaryScreen();
        QRect scr = screen->geometry();
        this->move(( scr.center() - rect().center() ));
        this->setWindowIcon(QIcon("/home/demo/.icons/myicon.png"));
    
    
        connect(ui->bthelpOk, SIGNAL(pressed()), this, SLOT(helpOk()));
    }
    
    help::~help()
    {
        delete ui;
    }
    
    void help::helpOk(){
        this->close();
    }
    
    

    and in main windows is call in these way ..

    void MainWindow::callHelphWindows(){
        m_help = new help();
        m_help->setWindowTitle(QApplication::translate("help", "HELP USER"));
        m_help->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
        m_help->resize(1024, 750);
        m_help->setFixedSize(1024, 750);
        m_help->setAttribute(Qt::WA_NoSystemBackground, true);
        m_help->setAttribute(Qt::WA_TranslucentBackground, true);
        m_help->setAttribute(Qt::WA_DeleteOnClose, true);
        m_help->setAttribute(Qt::WA_AcceptTouchEvents);
        m_help->getIndexPage(pageIndexGen);
        m_help->exec();
    
    
    }
    

    After these, if you use m_help with a classic mouse everything works .... but if you try to use it with the touch screen, after the first opening of my transparent QDialog I lose the ability of the touch of the touch on mainwindos.

    With the classic mouse, on the other hand, everything works as before .... so much so that I accidentally noticed the problem ...

    can anyone explain this problem to me?

    bkt

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

      Hi,

      It might be a bug, device issue, window manager issue, etc.

      You should add which version of Qt you are using as well as the platform you are running on.

      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,

        It might be a bug, device issue, window manager issue, etc.

        You should add which version of Qt you are using as well as the platform you are running on.

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

        @SGaist linux mint 18.03 qt5.12 .... but I use already a trasparent window at startup of app .... after these windows trasparent qdialog at startup is delete without any issue ..... but these second one after "delete ui" command seems not desappear for touch tap only, because touch cursor moove normally ...only is impossible use touch click\tap ..... maybe can be related to "QGuiApplication::primaryScreen();" call .... because that touch work only on prymary screen .... if SO->QT change screen prioriry can be a problem .... for touch .... can use other command type for put qtdialog trasparent on top of mainwindows (to prevent user click during upload process of app) ??

        bkt

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

          That's a bit vague of a description but "delete ui" does sound like you are deleting Designer based created object rather than the dialog containing it which might be one of the main issue.

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

          1 Reply Last reply
          1
          • gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by
            #5

            @gfxx said in QDialog Trasparent after close event loose touch tap event:

            help::~help()
            {
                 this->close();     /* ******can be a better solution for deleting QDialog? or need to delete from mainwindows?****** */
                 delete ui;
            }
            
            void help::helpOk(){
                this->close();
            }
            

            adding this->close(); can help? or need to add close method on mainwindows in your opinion?
            Can't make a test in these moment ... touch is on repair center after a damage ....

            bkt

            jsulmJ 1 Reply Last reply
            0
            • gfxxG gfxx

              @gfxx said in QDialog Trasparent after close event loose touch tap event:

              help::~help()
              {
                   this->close();     /* ******can be a better solution for deleting QDialog? or need to delete from mainwindows?****** */
                   delete ui;
              }
              
              void help::helpOk(){
                  this->close();
              }
              

              adding this->close(); can help? or need to add close method on mainwindows in your opinion?
              Can't make a test in these moment ... touch is on repair center after a damage ....

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @gfxx said in QDialog Trasparent after close event loose touch tap event:

              adding this->close(); can help?

              No, close() does not delete anything.
              If you created the dialog on the heap in main window then also delete it in main window with delete:

              void MainWindow::callHelphWindows(){
                  m_help = new help();
                  m_help->setWindowTitle(QApplication::translate("help", "HELP USER"));
                  m_help->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                  m_help->resize(1024, 750);
                  m_help->setFixedSize(1024, 750);
                  m_help->setAttribute(Qt::WA_NoSystemBackground, true);
                  m_help->setAttribute(Qt::WA_TranslucentBackground, true);
                  m_help->setAttribute(Qt::WA_DeleteOnClose, true);
                  m_help->setAttribute(Qt::WA_AcceptTouchEvents);
                  m_help->getIndexPage(pageIndexGen);
                  m_help->exec();
              
                  delete m_help;
              }
              

              But in this case you can simply allocate the dialog on the stack...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              gfxxG 1 Reply Last reply
              1
              • jsulmJ jsulm

                @gfxx said in QDialog Trasparent after close event loose touch tap event:

                adding this->close(); can help?

                No, close() does not delete anything.
                If you created the dialog on the heap in main window then also delete it in main window with delete:

                void MainWindow::callHelphWindows(){
                    m_help = new help();
                    m_help->setWindowTitle(QApplication::translate("help", "HELP USER"));
                    m_help->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                    m_help->resize(1024, 750);
                    m_help->setFixedSize(1024, 750);
                    m_help->setAttribute(Qt::WA_NoSystemBackground, true);
                    m_help->setAttribute(Qt::WA_TranslucentBackground, true);
                    m_help->setAttribute(Qt::WA_DeleteOnClose, true);
                    m_help->setAttribute(Qt::WA_AcceptTouchEvents);
                    m_help->getIndexPage(pageIndexGen);
                    m_help->exec();
                
                    delete m_help;
                }
                

                But in this case you can simply allocate the dialog on the stack...

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

                @jsulm delete m_help; crash app .... so try on stack ...and get double free or corruption error ........ and crash again ....

                ********* mainwindows.h**********
                private:
                    Ui::MainWindow *ui;
                    Login *m_login;
                    Help m_help;
                /* etc etc*/
                
                
                ********* mainwindows.cpp**********
                void MainWindow::callHelphWindows(){
                
                    m_help.setWindowTitle(QApplication::translate("help", "HELP UTENTE"));
                    m_help.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                    m_help.resize(1024, 760);
                    m_help.setFixedSize(1024, 760);
                    m_help.setAttribute(Qt::WA_NoSystemBackground, true);
                    m_help.setAttribute(Qt::WA_TranslucentBackground, true);
                    m_help.setAttribute(Qt::WA_DeleteOnClose, true);
                    m_help.setAttribute(Qt::WA_AcceptTouchEvents);
                    m_help.getHelpIdx(pageIndexGen);
                    m_help.exec();
                
                
                
                }
                

                bkt

                JonBJ 1 Reply Last reply
                0
                • gfxxG gfxx

                  @jsulm delete m_help; crash app .... so try on stack ...and get double free or corruption error ........ and crash again ....

                  ********* mainwindows.h**********
                  private:
                      Ui::MainWindow *ui;
                      Login *m_login;
                      Help m_help;
                  /* etc etc*/
                  
                  
                  ********* mainwindows.cpp**********
                  void MainWindow::callHelphWindows(){
                  
                      m_help.setWindowTitle(QApplication::translate("help", "HELP UTENTE"));
                      m_help.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                      m_help.resize(1024, 760);
                      m_help.setFixedSize(1024, 760);
                      m_help.setAttribute(Qt::WA_NoSystemBackground, true);
                      m_help.setAttribute(Qt::WA_TranslucentBackground, true);
                      m_help.setAttribute(Qt::WA_DeleteOnClose, true);
                      m_help.setAttribute(Qt::WA_AcceptTouchEvents);
                      m_help.getHelpIdx(pageIndexGen);
                      m_help.exec();
                  
                  
                  
                  }
                  
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @gfxx

                  m_help->setAttribute(Qt::WA_DeleteOnClose, true);

                  If you use this, don't delete it.

                  gfxxG 1 Reply Last reply
                  1
                  • JonBJ JonB

                    @gfxx

                    m_help->setAttribute(Qt::WA_DeleteOnClose, true);

                    If you use this, don't delete it.

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

                    @JonB thanks ... so again on heap ... @@@ HEAP @@@

                    void MainWindow::callHelphWindows(){
                       
                        m_help = new Help();
                        m_help->setWindowTitle(QApplication::translate("help", "HELP UTENTE"));
                        m_help->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                        m_help->resize(1024, 760);
                        m_help->setFixedSize(1024, 760);
                        m_help->setAttribute(Qt::WA_NoSystemBackground, true);
                        m_help->setAttribute(Qt::WA_TranslucentBackground, true);
                        //m_help->setAttribute(Qt::WA_DeleteOnClose, true);
                        m_help->setAttribute(Qt::WA_AcceptTouchEvents);
                        m_help->getHelpIdx(pageIndexGen);
                        m_help->exec();
                    
                    
                    }
                    

                    bkt

                    JonBJ 1 Reply Last reply
                    0
                    • gfxxG gfxx

                      @JonB thanks ... so again on heap ... @@@ HEAP @@@

                      void MainWindow::callHelphWindows(){
                         
                          m_help = new Help();
                          m_help->setWindowTitle(QApplication::translate("help", "HELP UTENTE"));
                          m_help->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);
                          m_help->resize(1024, 760);
                          m_help->setFixedSize(1024, 760);
                          m_help->setAttribute(Qt::WA_NoSystemBackground, true);
                          m_help->setAttribute(Qt::WA_TranslucentBackground, true);
                          //m_help->setAttribute(Qt::WA_DeleteOnClose, true);
                          m_help->setAttribute(Qt::WA_AcceptTouchEvents);
                          m_help->getHelpIdx(pageIndexGen);
                          m_help->exec();
                      
                      
                      }
                      
                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @gfxx
                      Now you have changed it so it leaks the m_help = new Help();....

                      gfxxG 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @gfxx
                        Now you have changed it so it leaks the m_help = new Help();....

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

                        @JonB you refer to @@@ HEAP @@@ tag reply?

                        So need to use :

                        @@@ heap @@@
                        Help *m_help; => m_help = new Help(); m_help->setWindowTitle(QApplication::translate("help", "HELP UTENTE"));

                        or

                        @@@ stack @@@
                        Help m_help; => m_help.setWindowTitle(QApplication::translate("help", "HELP UTENTE"));

                        instead??

                        bkt

                        JonBJ 1 Reply Last reply
                        0
                        • gfxxG gfxx

                          @JonB you refer to @@@ HEAP @@@ tag reply?

                          So need to use :

                          @@@ heap @@@
                          Help *m_help; => m_help = new Help(); m_help->setWindowTitle(QApplication::translate("help", "HELP UTENTE"));

                          or

                          @@@ stack @@@
                          Help m_help; => m_help.setWindowTitle(QApplication::translate("help", "HELP UTENTE"));

                          instead??

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #12

                          @gfxx
                          Have you just looked at the documentation for the Qt::WA_DeleteOnClose attribute you are adding? What do you think it does?

                          It is very simple:

                          • If you set it true, do not delete.
                          • If you set it false (default), do delete.
                          gfxxG 1 Reply Last reply
                          2
                          • JonBJ JonB

                            @gfxx
                            Have you just looked at the documentation for the Qt::WA_DeleteOnClose attribute you are adding? What do you think it does?

                            It is very simple:

                            • If you set it true, do not delete.
                            • If you set it false (default), do delete.
                            gfxxG Offline
                            gfxxG Offline
                            gfxx
                            wrote on last edited by gfxx
                            #13

                            @JonB .... really no ... sorry ... But now understand ... so heap and stack hss nothing to do in these case seems ....

                            When can try on touch (with problem) I update the post as solved.

                            For now:

                            real thanks

                            problem was solved commented out WA_DeleteOnClose macro, thanks again.

                            bkt

                            1 Reply Last reply
                            1

                            • Login

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