Touch coordinates offset in QMessageBox when Qt::FramelessWindowHint is set
-
I found that my QMessageBox was not responding to touch events whenever the Qt::FramelessWindowHint window flag is set. When cleared, the dialog responds normally.
This is my code,
QMessageBox msg(this);
msg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setButtonText(QMessageBox::Ok , "Run");
msg.setButtonText(QMessageBox::Cancel , "Back");
if(msg.exec() == QMessageBox::Ok)
{
qDebug()<<"OK";
}how to fix the bug ?
Thank you. -
Hi,
There are missing information:
- Qt version ?
- OS ?
- if Linux, which distribution ?
- touch screen ?
- Device ?
- self-built Qt ?
etc.
-
Hi,
There are missing information:
- Qt version ?
- OS ?
- if Linux, which distribution ?
- touch screen ?
- Device ?
- self-built Qt ?
etc.
QT Version :
Qt Creator 4.8.2
Based on Qt 5.11.3 (GCC 8.3.0, 32 bit)OS :
Raspberry pi os (Legacy) ---- Linux
Yes, touch screenOne more doubt
for Alternative code,
How to disable minimize, maximize and close options in message box without using framelesswindow hint?
-
That's the Qt Creator version. It has nothing to do with the version of Qt you are using to build your application.
Check the Qt::WindowCloseButtonHint and friend flags that you can set on your widget.
-
That's the Qt Creator version. It has nothing to do with the version of Qt you are using to build your application.
Check the Qt::WindowCloseButtonHint and friend flags that you can set on your widget.
-
@Ramkumar-Mohan By unsetting Qt::WindowMinimizeButtonHint flag on your dialog (https://doc.qt.io/qt-6/qmessagebox.html#QMessageBox-1)
-
@Ramkumar-Mohan By unsetting Qt::WindowMinimizeButtonHint flag on your dialog (https://doc.qt.io/qt-6/qmessagebox.html#QMessageBox-1)
msg.setWindowFlags(Qt::Dialog | Qt::WindowMinimizeButtonHint);
I'm Setting this code , but not worked for me . i don't know
how to set the code .
Thank you. -
msg.setWindowFlags(Qt::Dialog | Qt::WindowMinimizeButtonHint);
I'm Setting this code , but not worked for me . i don't know
how to set the code .
Thank you.@Ramkumar-Mohan Please show the whole code where you're showing the message box. Also, on which OS are you?
-
@Ramkumar-Mohan By unsetting Qt::WindowMinimizeButtonHint flag on your dialog (https://doc.qt.io/qt-6/qmessagebox.html#QMessageBox-1)
@jsulm said in Touch coordinates offset in QMessageBox when Qt::FramelessWindowHint is set:
@Ramkumar-Mohan By unsetting Qt::WindowMinimizeButtonHint flag
@Ramkumar-Mohan said in Touch coordinates offset in QMessageBox when Qt::FramelessWindowHint is set:
msg.setWindowFlags(Qt::Dialog | Qt::WindowMinimizeButtonHint);As @jsulm said, if you want not to have a "minimize button" you need to unset/clear the
Qt::WindowMinimizeButtonHintflag, not set it. -
@Ramkumar-Mohan Please show the whole code where you're showing the message box. Also, on which OS are you?
This my code ,
QMessageBox msg(this);
msg.setWindowFlags(msgBox.windowFlags()&(~ Qt::WindowMinimizeButtonHint));
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setButtonText(QMessageBox::Ok , "Run");
msg.setButtonText(QMessageBox::Cancel , "Back");
if(msg.exec() == QMessageBox::Ok)
{
qDebug()<<"OK";
}I wrote the code for remove Minimize Button , but the code is not working properly,
I run the code but it showing the minimize button , and i click the minimize button .( Closed the whole Running page) where the error , i don't think to how to solve it ,
Please give any resolving suggestion to me ,Thank you.
-
This my code ,
QMessageBox msg(this);
msg.setWindowFlags(msgBox.windowFlags()&(~ Qt::WindowMinimizeButtonHint));
msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msg.setButtonText(QMessageBox::Ok , "Run");
msg.setButtonText(QMessageBox::Cancel , "Back");
if(msg.exec() == QMessageBox::Ok)
{
qDebug()<<"OK";
}I wrote the code for remove Minimize Button , but the code is not working properly,
I run the code but it showing the minimize button , and i click the minimize button .( Closed the whole Running page) where the error , i don't think to how to solve it ,
Please give any resolving suggestion to me ,Thank you.
@Ramkumar-Mohan said in Touch coordinates offset in QMessageBox when Qt::FramelessWindowHint is set:
msg.setWindowFlags(msgBox.windowFlags()&(~ Qt::WindowMinimizeButtonHint));That is better! And the best that you can do.
WindowMinimizeButtonHintis a hint, I believe that not all windowing systems respect it. If you download the Window Flags Example and play with it you can find out which flags work how on your platform. -
@Ramkumar-Mohan said in Touch coordinates offset in QMessageBox when Qt::FramelessWindowHint is set:
msg.setWindowFlags(msgBox.windowFlags()&(~ Qt::WindowMinimizeButtonHint));That is better! And the best that you can do.
WindowMinimizeButtonHintis a hint, I believe that not all windowing systems respect it. If you download the Window Flags Example and play with it you can find out which flags work how on your platform.That problem has been solved. Now that's working fine. Thank you.