[Interest] The touch screen events are block after deleteLater function

g.scarpelli at u-tech.it g.scarpelli at u-tech.it
Thu Feb 16 10:53:06 CET 2023


   Hi,

   I am development my application with the qt 5.15 (c++ code) .The my application is implement using objects are child of the QWidget class. Every time that I open a child class connect the closing signal at the slot to parent class to delete the object child :

   PARENT CLASS :
   windows = new ChildClass ( ) ;
   connect (childClass,&childClass::signalClose,parentClass,&parentClass::closeChildClass);
   windows-> showFullScreen ( ) ;

   CHILD CLASS :
   emit signalClose ( ) ;

   PARENT CLASS :
   slot closeChildClass :
   windows-> deleteLater ( ) ;

   I have Implement a application to execute this simple code, if I can keep press the touch screen with my finger when the application execute the windows-> deleteLater ( ) instruction, the touch screen is freeze, I don't can to press the button of the my application with the display touch. While if I connect the mouse I can press the button correctly, but if to press button with the finger not spring the &QPushButton::released event. If I can to active &QPushButton::released event with mouse, means that my application is not block and the button is enabled. If I comment the windows-> deleteLater ( ) instruction I don't this problem. Afer that problem occurred if I restart the application it work correctly, without power off the pc, so the display touch work correcty.

   Can you help me ?
   This problem blocking the release the my application !
   Thanks

   ----------------------- home.h -------------------------`
   #ifndef HOME_H
   #define HOME_H
   #include <QWidget>
   //---------------------
   //INCLUDE VALIDI PER TUTTE LE FINESTRE
   #include <QScreen>
   #include <QDebug>
   #include <QTimer>
   #include <QDateTime>
   #include <QFile>
   #include <QJsonDocument>
   #include <QJsonValue>
   #include <QJsonArray>
   #include <QJsonObject>
   #include <QFileInfo>
   #include <QSqlDatabase>
   #include <QSqlError>
   #include <QSqlQuery>
   #include <QMessageLogContext>
   #include <QLoggingCategory>
   //---------------------
   #include "lavaggio.h"
   #include <QtGui>
   #include <QPainter>
   #include <QStyleOption>
   #include <QDir>
   namespace Ui {
   class Home;
   }
   class Home : public QWidget
   {
       Q_OBJECT
   public:
       explicit Home ( Init *tmp_init = nullptr, QWidget *parent = nullptr ) ;
       ~Home();
    protected:
       void paintEvent(QPaintEvent *)
       {
           QStyleOption opt;
           opt.init(this);
           QPainter p(this);
           style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
       }
   signals :
   public slots :
      void openAvvioLavaggio();
      void closeAvvioLavaggio();
   private slots:

   private :
       Ui::Home *ui ;
       Lavaggio *window = nullptr ;
   } ;
   #endif // HOME_H
   ----------------------- home.cpp -------------------------
   Home::Home (Init * tmp_init , QWidget * parent ) :
       QWidget ( parent ) ,
       ui ( new Ui::Home )
   {
       qDebug ( ) << "Load Home" ;
       ui->setupUi(this);
       this -> setWindowFlags ( Qt::Window | Qt::CustomizeWindowHint ) ;
   connect(ui->btn_avvio_lavaggio, &QPushButton::released, this, &Home::openAvvioLavaggio);
   }
   void Home::openAvvioLavaggio(){
       qDebug ( ) <<"Start 'wash'.";
       // creo istanza oggetto finestra Avvio Lavaggio
       window= new Lavaggio();
       //collego slot-signal all'eventi di chiusura del widget
       // Note : time to execute this instruction about 500ms
       connect(window,&Lavaggio::closeLavaggio,this,&Home::closeAvvioLavaggio);
       //visualizzo schermata Avvio Lavaggio
       window->showFullScreen();
       // Remove the 'stays on top hint'
       this -> setWindowFlags ( Qt::Window | Qt::CustomizeWindowHint ) ;

   }
   void Home::closeAvvioLavaggio()
   {
       qDebug ( ) <<"closeAvvioLavaggio";
       //scollego slot-signal all'eventi di chiusura del widget
       disconnect(window,&Lavaggio::closeLavaggio,this,&Home::closeAvvioLavaggio);
       window->deleteLater();
       window = nullptr ;
   }
   ----------------------- lavaggio.h -------------------------
   #ifndef LAVAGGIO_H
   #define LAVAGGIO_H
   #include <QWidget>
   //---------------------
   //INCLUDE VALIDI PER TUTTE LE FINESTRE
   #include <QScreen>
   #include <QDebug>
   #include <QTimer>
   #include <QDateTime>
   #include <QProcess>
   #include <QFile>
   #include <QJsonDocument>
   #include <QJsonValue>
   #include <QJsonArray>
   #include <QJsonObject>
   #include <QFileInfo>
   #include <QSqlDatabase>
   #include <QSqlError>
   #include <QSqlQuery>
   #include <QSqlRecord>
   #include <QtGui>
   #include <QPainter>
   #include <QStyleOption>
   //---------------------
   #include "pagamentolavaggioasciugatura.h"
   #include "messagebox.h"
   #include "ChooseTypeWash.h"
   #include "laundrysettings.h"
   #include "laundryapp.h"
   namespace Ui {
   class Lavaggio;
   }
   class Lavaggio : public QWidget
   {
       Q_OBJECT
   public:
       explicit Lavaggio( QWidget *parent = nullptr);
       ~Lavaggio();

   protected:
       void paintEvent(QPaintEvent *)
       {
           QStyleOption opt;
           opt.init(this);
           QPainter p(this);
           style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
       }
   signals :
       // Close the window
       void closeLavaggio ( ) ;
   private slots:
       // Exit from screen
       void exitWash ( ) ;
   private:
       Ui::Lavaggio *ui;
   } ;
   #endif // LAVAGGIO_H
   ----------------------- lavaggio.cpp -------------------------
   Lavaggio::Lavaggio ( QWidget *parent ) :
       QWidget(parent),
       ui(new Ui::Lavaggio)
   {
       qDebug ( ) <<"Load Lavaggio";
       //--------------------------------------
       //CARICAMENTO GRAFICA
       //avvio caricamento grafica
       ui->setupUi(this);
       // --------------------------------------
       // PERSONALIZZAZIONE GRAFICA
       // queste impostazioni grafiche devono valere per tutte le finestre
       // per eliminare la toolbar
       // Note: Time to execute this instruction about 500ms
       this->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint );
       connect(ui->btn_indietro, &QPushButton::released, this, &Lavaggio::exitWash);
   }
   void Lavaggio::exitWash ( ) {
       qDebug ( ) <<"Check Exit wash" ;
           qDebug ( ) << "Exit -> wash" ;
           emit closeLavaggio ( ) ;
           close ( ) ;

   }

   [microtechsrl_1486503464_F.png]

   *-*-*-*-*-*-*-*-*-*-*-*-*
   Dot. Gianmarco Scarpelli
   Microtech Srl
   Via Mameli, 94
   53043 Chiusi (Si)
   http://www.microtechsrl.net
   Tel +39 0578 294621
   Fax +39 0578 1900218
   ************************
   Attenzione: Le informazioni contenute in questo messaggio di posta elettronica sono private e confidenziali, riservate solo all'attenzione del destinatario. Qualora doveste ricevere questo messaggio per errore, Vi notifichiamo con la presente che ogni diffusione, riproduzione, distribuzione o utilizzo del presente messaggio è altamente proibita. Siete pregati di informare il mittente con un messaggio di risposta e cancellare immediatamente il presente messaggio ed il suo eventuale contenuto, senza copiarlo o aprirlo.
   *****************************************************
   This e-mail and any file transmitted with it, which may contain confidential and/or privileged material, is legally privileged and intended solely for the recipient. Access to this e-mail by anyone else, use it for any purpose, store, copy, disclose the contents to any other person totally or partially is strictly prohibited and illegal. If you are not the intended recipient(s), please do not read this e-mail, delete this message and any attachments from your system and contact the sender by reply e-mail or by telephone.
   *****************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230216/ac590aaf/attachment.htm>


More information about the Interest mailing list