The touch screen events are block after deleteLater function
-
Hello guys,
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 ( )
disconnect(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 -
Hello guys,
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 ( )
disconnect(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@GianmarcoUtech said in The touch screen events are block after deleteLater function:
PARENT CLASS :
windows = new ChildClass ( ) ;
connect ( )
disconnect(childClass,&childClass::signalClose,parentClass,&parentClass::closeChildClass);
windows-> showFullScreen ( ) ;
CHILD CLASS :
emit signalClose ( ) ;
PARENT CLASS :
slot closeChildClass :
windows-> deleteLater ( ) ;I don't understand this: you create a child class and name the object "windows", but then you connect an object called "childClass"? Why?! And why do you call disconnect instead of connect? Can you please post proper code you're using?
-
@GianmarcoUtech said in The touch screen events are block after deleteLater function:
PARENT CLASS :
windows = new ChildClass ( ) ;
connect ( )
disconnect(childClass,&childClass::signalClose,parentClass,&parentClass::closeChildClass);
windows-> showFullScreen ( ) ;
CHILD CLASS :
emit signalClose ( ) ;
PARENT CLASS :
slot closeChildClass :
windows-> deleteLater ( ) ;I don't understand this: you create a child class and name the object "windows", but then you connect an object called "childClass"? Why?! And why do you call disconnect instead of connect? Can you please post proper code you're using?
@jsulm okay,
----------------------- home.h -------------------------```
code_text#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 ( ) ; } -
@jsulm okay,
----------------------- home.h -------------------------```
code_text#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 ( ) ; }@GianmarcoUtech said in The touch screen events are block after deleteLater function:
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 ;}
Did you try to call this->show() or this->showFullScreen() inside closeAvvioLavaggio?
-
@GianmarcoUtech said in The touch screen events are block after deleteLater function:
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 ;}
Did you try to call this->show() or this->showFullScreen() inside closeAvvioLavaggio?
@jsulm said in The touch screen events are block after deleteLater function:
Did you try to call this->show() or this->showFullScreen() inside closeAvvioLavaggio?
Do you think that could be the cause of the problem?
I need to display the widget full screen, so that the user can't press behind the widget.
-
@jsulm said in The touch screen events are block after deleteLater function:
Did you try to call this->show() or this->showFullScreen() inside closeAvvioLavaggio?
Do you think that could be the cause of the problem?
I need to display the widget full screen, so that the user can't press behind the widget.
@GianmarcoUtech said in The touch screen events are block after deleteLater function:
I need to display the widget full screen, so that the user can't press behind the widget
Yes, but as soon as the child widget is closed you want to show the main window again, right?
-
@GianmarcoUtech said in The touch screen events are block after deleteLater function:
I need to display the widget full screen, so that the user can't press behind the widget
Yes, but as soon as the child widget is closed you want to show the main window again, right?
@jsulm said in The touch screen events are block after deleteLater function:
Yes, but as soon as the child widget is closed you want to show the main window again, right?
Yes it's right, but in really the parent screen is already open, under the child screen, the parent screen is show when is close the child screen.
-
@jsulm said in The touch screen events are block after deleteLater function:
Yes, but as soon as the child widget is closed you want to show the main window again, right?
Yes it's right, but in really the parent screen is already open, under the child screen, the parent screen is show when is close the child screen.
@jsulm sorry for the insistence, for me is important understand the origin of the problem, because it am blocking the delivery of the projects developed with qt. Thanks
-
@jsulm sorry for the insistence, for me is important understand the origin of the problem, because it am blocking the delivery of the projects developed with qt. Thanks
@GianmarcoUtech Sorry, but currently I'm out of ideas.
-
@GianmarcoUtech Sorry, but currently I'm out of ideas.
@jsulm You know who I can contact to resolve my problem ?
Thanks
-
@jsulm You know who I can contact to resolve my problem ?
Thanks
@GianmarcoUtech Qt 5 has update problems on touch screen.
A workaround may be to hide windowvoid Home::closeAvvioLavaggio() { qDebug ( ) <<"closeAvvioLavaggio"; //scollego slot-signal all'eventi di chiusura del widget disconnect( window,&Lavaggio::closeLavaggio, this, &Home::closeAvvioLavaggio); window->setVisible( false ); /* do not delete it now, simply hide it since I assume it is not big */ }Delete it in the destructor of Home
-
@GianmarcoUtech Qt 5 has update problems on touch screen.
A workaround may be to hide windowvoid Home::closeAvvioLavaggio() { qDebug ( ) <<"closeAvvioLavaggio"; //scollego slot-signal all'eventi di chiusura del widget disconnect( window,&Lavaggio::closeLavaggio, this, &Home::closeAvvioLavaggio); window->setVisible( false ); /* do not delete it now, simply hide it since I assume it is not big */ }Delete it in the destructor of Home
@JoeCFD The your idea its correct, but hiding the window without deleting the object creates an increase in memory occupation. Because using NEW (in the openAvvioLavaggio function) you create new objects that are never deleted. Then my application has many child windows to manage.
-
@JoeCFD The your idea its correct, but hiding the window without deleting the object creates an increase in memory occupation. Because using NEW (in the openAvvioLavaggio function) you create new objects that are never deleted. Then my application has many child windows to manage.
@GianmarcoUtech There is no need to delete and recreate the window all the time. Simply show and hide one existing window...
-
@GianmarcoUtech There is no need to delete and recreate the window all the time. Simply show and hide one existing window...
@jsulm It's true, but there are almost 50 screens, it takes a long time to modify all of them and the application has been consolidated for a couple of years, I would like to modify as little as possible. But actually I would like to understand why deleting an object with delayLater causes this problem with the touch, I would like to understand if it is my problem or a qt bug. It seems very strange to me that this hasn't happened to any other developer.
-
@jsulm It's true, but there are almost 50 screens, it takes a long time to modify all of them and the application has been consolidated for a couple of years, I would like to modify as little as possible. But actually I would like to understand why deleting an object with delayLater causes this problem with the touch, I would like to understand if it is my problem or a qt bug. It seems very strange to me that this hasn't happened to any other developer.
@GianmarcoUtech It may also be related to the drivers for touch screen. But I guess it is more a Qt issue.
Can you try to set focus or call update or both to Home after
window->deleteLater(); window = nullptr ; -
@GianmarcoUtech It may also be related to the drivers for touch screen. But I guess it is more a Qt issue.
Can you try to set focus or call update or both to Home after
window->deleteLater(); window = nullptr ;I have tried , but I have not resolved:
void Home::closeAvvioLavaggio() { disconnect(window,&Lavaggio::closeLavaggio,this,&Home::closeAvvioLavaggio); window->deleteLater(); window = nullptr ; this->update ( ) ; this->setFocus ( ) ; } -
I have tried , but I have not resolved:
void Home::closeAvvioLavaggio() { disconnect(window,&Lavaggio::closeLavaggio,this,&Home::closeAvvioLavaggio); window->deleteLater(); window = nullptr ; this->update ( ) ; this->setFocus ( ) ; }@GianmarcoUtech Can you also try to assign Home to the parent of window
delete window;
window = nullptr;Home is frozen often because it lost focus and does not update.
-
@GianmarcoUtech Can you also try to assign Home to the parent of window
delete window;
window = nullptr;Home is frozen often because it lost focus and does not update.
@JoeCFD So how should I modify my code?
-
@JoeCFD So how should I modify my code?
@GianmarcoUtech
I guess window is a fullscreen pop-up, right? If yes, you may not be able to do it.
Otherwise, you can do
window= new Lavaggio( this );Anyway, what I am suggesting is to somehow update your gui after window is deleted. If you can update any widget on your GUI after the delete, it will help since the update of any widget will cause the whole GUI to update.
-
@GianmarcoUtech
I guess window is a fullscreen pop-up, right? If yes, you may not be able to do it.
Otherwise, you can do
window= new Lavaggio( this );Anyway, what I am suggesting is to somehow update your gui after window is deleted. If you can update any widget on your GUI after the delete, it will help since the update of any widget will cause the whole GUI to update.
@JoeCFD I have understand the your suggesting. Is a idea very interesent, but I can't put it into practice, because I know olny the functions setFocus and update. I have looking for on qt manual, but I have not find anything interesting. I testing this code but unfortunately not work :
void Home::closeAvvioLavaggio()
{
disconnect(window,&Lavaggio::closeLavaggio,this,&Home::closeAvvioLavaggio);
window->deleteLater();
window = nullptr ;this->setFocus ( ) ; this->update ( ) ;}
void Home::openAvvioLavaggio(){
qDebug ( ) <<"Start 'wash'."; // creo istanza oggetto finestra Avvio Lavaggio window= new Lavaggio(this); //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 ) ;}