X11, Frameless dialog not visible after hiding/showing it quickly
-
Hi,
I am working in a project where I have two windows A and B.
- I show window A when the "customContextMenuRequested" is emmited in B (this signal is emmited when right clicking on B)--.
- Then in the "showEvent" of A, I install an event filter on B to catch the left clicks on B.
- When left clicking on B, the "eventFiler" method of A is called and hides A.
- In the "hideEvent" of A, I remove the event filter set on B.
When I left-click/right-click rapidly on window B with window A is created with "Qt::FramelessWindowHint", at a certain point, window A does not show anymore.
I can still right-click and left-click on B and the "showEvent" and "hideEvent" of A are still called but the window is not visible on the desktop.
The problem does not occur when A has a frame, or when I run the program without a window manager.
It does not occur either on Windows.I extracted the issue from the actual program and try managed to reproduce it with the following code:
"MyWidget" is the class of object A, with overloaded events:
@#include <QDialog>
#include <QWidget>
#include <QMouseEvent>class MyWidget : public QDialog
{
Q_OBJECTQWidget* m_pwWidget;
public:
MyWidget(QWidget* pwWidget) : QDialog(NULL,Qt::FramelessWindowHint), m_pwWidget(pwWidget) {}
protected:
virtual bool eventFilter(QObject , QEvent p_peEvent)
{
switch(p_peEvent->type()){
case QEvent::MouseButtonPress:
if(static_cast<QMouseEvent>(p_peEvent)->button() == Qt::LeftButton)
close();
break;
default:
break;
}
return false;
}
virtual void showEvent(QShowEvent)
{
m_pwWidget->installEventFilter(this);
}
virtual void hideEvent(QHideEvent *)
{
m_pwWidget->removeEventFilter(this);
}
public slots:
void customContextMenuSlot(QPoint)
{
show();
}
};@The main function follows:
@int main(int argc, char** argv)
{
QApplication app(argc,argv);QWidget* B = new QWidget; B->resize(200,200); B->setContextMenuPolicy(Qt::CustomContextMenu); MyWidget* A = new MyWidget(B); A->resize(200,200); QObject::connect(B,SIGNAL(customContextMenuRequested(QPoint)),A,SLOT(customContextMenuSlot(QPoint))); B->show(); app.exec();
}@
It is a little bit harder to reproduce the issue in release than in debug.
Does anyone knows if something is wrong in the previous code, or if it might be a window manager compatibility issue, or a bug in qt.
Thanks
-
Hi and welcome to devnet,
It doesn't look wrong, so you may have found something. You should have a look at the "bug report system":http://bureports.qt-project.org to see if it's something known. If not please consider opening a new report providing a minimal compilable example (with the code you are showing here)
-
Hi thibault,
Found your post when searching for the QDialog not showing issue. I also encounter similar problem on X11. After hiding/showing a frameless QDialog rapidly, it is not visible on screen anymore. I have dumped the properties of the widget tree, all the widgets are visible. So I suspect it could be related to X11.
If I removed the Qt::FramelessWindowHint, the QDialog will be shown correctly all the time.
Have you found any solution/workaround for the problem you reported?
Thanks.