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

[REG 4->5] Qt 5 QWidget::grabMouse(QCursor) does not change the cursor.

    XMLWordPrintable

Details

    • 135e9d5a8286e5abd35e04213c232d73c2df15b5 (dev, 3.7.2014, 5.4)

    Description

      #include <QApplication>
      #include <QCursor>
      #include <QDebug>
      #include <QPushButton>
      
      class Widget : public QPushButton
      {
          Q_OBJECT
      
      public:
          Widget()
          {
              m_on = false;
              connect(this, SIGNAL(clicked()), this, SLOT(onClicked()));
          }
      
          bool event(QEvent *ev)
          {
              qDebug() << ev->type();
              return QPushButton::event(ev);
          }
      
          Q_SLOT void onClicked()
          {
              m_on = !m_on;
              if (m_on)
                  grabMouse(Qt::CrossCursor);
              else
                  releaseMouse();
          }
      
          bool m_on;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          w.show();
      
          return a.exec();
      }
      
      #include "main.moc"
      

      With Qt 4 I see a cross-hair cursor, with Qt 5 not.

      The sequence of events is also quite different (in both case click on widget, move mouse to some place outside, click, move back to widget, click):

      Qt 4:

      203 75 13 14 17 26 74 77 13 12 10 24 99 8 77 12 2 77 12 77 3 77 12 77 2 3 2 77 12 77 3 77 12 77 11 25 99 9 77 12

      Qt 5:

      203 34 75 13 14 17 183 26 74 78 77 14 13 12 24 99 8 207 77 12 10 127 129 77 12 129 129 129 129 129 129 2 77 12 77 3 77 12 77 129 129 129 129 11 128 129 77 12 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 2 3 77 12 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 129 10 127 129 77 12 129 129 129 129 129 129 129 129 129 129 129 129 129 2 77 12 77 3 77 12 77 129 129 129 129 129 11 128 77 12 23 23 25 99 9 77 12

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            hjk hjk
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes