Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-4627

When a widget is hidden/shown with the cursor over it then a mouse move event is sent on Windows

    XMLWordPrintable

Details

    Description

      When a widget is hidden/shown with the cursor over it then a mouse move event is sent on Windows. This only happens when the widget being hidden is not a native widget, if it is a native one then only the enter/leave is sent as expected.

      #include <QtGui>
      
      class MyWidget : public QWidget
      {
      public:
          MyWidget(const QColor &col, QWidget *parent = 0) : QWidget(parent) 
          { 
              setAutoFillBackground(true); 
              QPalette pal = palette(); 
              pal.setColor(QPalette::Window, col); 
              setPalette(pal); 
              setMouseTracking(true);
          }
      protected:
          void enterEvent(QEvent *e)
          {
              qDebug() << "Enter Event" << this;
          }
          void leaveEvent(QEvent *e)
          {
              qDebug() << "Leave Event" << this;
          }
          void mouseMoveEvent(QMouseEvent *e)
          {
              qDebug() << "Mouse Move Event" << this;
          }
      };
      
      int main(int argc, char **argv)
      {
          QApplication a(argc, argv);
          //a.setAttribute(Qt::AA_NativeWindows);
          MyWidget w(Qt::blue);
          w.setFixedSize(500, 500);
          QPushButton *pb = new QPushButton("Hide", &w);
          QPushButton *pb2 = new QPushButton("Show", &w);
          pb2->move(100, 0);
          MyWidget *child = new MyWidget(Qt::red, &w);
          child->setFixedSize(200, 200);
          child->move(50, 50);
          QObject::connect(pb, SIGNAL(clicked()), child, SLOT(hide())); 
          QObject::connect(pb2, SIGNAL(clicked()), child, SLOT(show()));
          w.show();
          return a.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            anshaw Andy Shaw (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes