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

QEvent::HoverLeave is not always sent to a Widget in graphics view

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.6.0
    • 4.5.3
    • Widgets: GraphicsView
    • None

    Description

      In some cases, the event QEvent::HoverLeave is never sent to a widget inside graphics view. The widgets keep the hover state even when the mouse has left the widget.

      This can be reproduced with the styles Oxygen and Windows XP.

      Here is an exemple to reproduce the problem. If you click on the last pixel of the border of the top button, the button below remains in hover state.

      #include <QtGui>

      class VerboseButton : public QPushButton
      {
      bool event(QEvent* e)
      {
      if (QEvent::HoverEnter == e->type())

      { qDebug("QEvent::HoverEnter"); }

      else if(QEvent::HoverLeave == e->type())

      { qDebug("QEvent::HoverLeave"); }

      else if(QEvent::HoverMove == e->type())

      { qDebug("QEvent::HoverMove"); }

      else if(QEvent::Enter == e->type())

      { qDebug("QEvent::Enter"); }

      else if(QEvent::Leave == e->type())

      { qDebug("QEvent::Leave"); }

      return QPushButton::event(e);
      }
      };

      class Scene : public QGraphicsScene
      {
      Q_OBJECT
      public:
      Scene()

      { QWidget *background = new QWidget; background->setGeometry(0, 0, 500, 500); VerboseButton *verboseButton = new VerboseButton; verboseButton->setParent(background); verboseButton->setText("This button should not keep the focus when the mouse is out"); verboseButton->setGeometry(10, 10, 400, 50); addWidget(background); connect(verboseButton, SIGNAL(clicked()), this, SLOT(showButton())); QPushButton *hideButton = new QPushButton("Click to hide (put the mouse on the decoration border)"); hideButton->setGeometry(10, 10, 400, 50); topButton = addWidget(hideButton); connect(hideButton, SIGNAL(clicked()), this, SLOT(hideButton())); }

      public slots:
      void hideButton()

      { topButton->hide(); }

      void showButton()

      { topButton->show(); }

      private:
      QGraphicsProxyWidget *topButton;
      };

      #include "main.moc"

      int main(int argc, char **argv){
      QApplication app(argc, argv);
      QGraphicsView view;
      Scene scene;
      view.setScene(&scene);
      view.resize(600, 600);
      view.show();
      return app.exec();
      }

      Attachments

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

        Activity

          People

            monsen Marius Bugge Monsen
            poulain Benjamin Poulain (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