Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.4.3
-
None
Description
I have found a case in which QWidget::underMouse does not return a correct
value.
If you delete a widget and then another widget has the mouse under, if you
don't move the mouse and ask if that new widget has the mouse under it says
no.
I attach an example code, there if i click on label 0 it will disappear and
label 1 will take its place, if without moving the mouse you click the mouse
again you will see it does not disappear even you really have the mouse over
the widget.
This is reproducible for me using Qt in X11 on KDE 4.2 not sure if that might
work or not on Windows/Mac or some other X11 window manager.
Example:
#include <QApplication>
#include <QDebug>
#include <QLabel>
#include <QVBoxLayout>
class MyWidget : public QLabel
{
protected:
void mousePressEvent(QMouseEvent *e)
{
if (underMouse())
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *w = new QWidget();
QVBoxLayout *l = new QVBoxLayout(w);
l->setMargin(0);
l->setSpacing(0);
w->show();
for (int i = 0; i < 5; ++i)
{ MyWidget *mw = new MyWidget(); mw->setFrameStyle(QFrame::Panel | QFrame::Raised); mw->setLineWidth(2); mw->setMinimumSize(50, 50); mw->setText(QString::number(i)); l->addWidget(mw); } return a.exec();
}