QDialog Trasparent after close event loose touch tap event
-
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?
-
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.
-
@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) ??
-
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.
-
@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 .... -
@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...
-
@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(); }
-
@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(); }
-
@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??
-
@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.