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

After obtaining the winId of a widget control, it fails to receive hovering TabletMove events.

    XMLWordPrintable

Details

    • Windows

    Description

      After obtaining the winId of a widget control, it fails to receive hovering TabletMove events.

      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          m_formView = new Form(this);
      //    m_formView->winId();
          m_formView->installEventFilter(this);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      bool MainWindow::eventFilter(QObject *obj, QEvent *event)
      {
      
          if(event->type() == QEvent::TabletMove ||
                  event->type() == QEvent::TabletPress ||
                  event->type() == QEvent::TabletRelease ||
                  event->type() == QEvent::TabletEnterProximity ||
                  event->type() == QEvent::TabletLeaveProximity ||
                  event->type() == QEvent::TabletTrackingChange
                  ){
              qInfo() << "eventFilter Tablet evevt:" << event;
      
              QTabletEvent *tabletEvent = static_cast<QTabletEvent*>(event);
      
              tabletEvent->buttons();
              tabletEvent->accept();
              return true;
          }
      
          return false;
      }
      

       

      Furthermore, according to the description of QTabletEvent on the QT official documentation, when a small widget accepts a QTabletEvent, it should not generate mouse events. However, in my eventFilter process, I have already marked the tabletEvent as accepted and returned true. Despite this, when the stylus is in a hover state, I still receive QMouseMove events.

       

       I've also tried the approach below, but it didn't work.

      //代码占位符
          // All tablet events that are not accepted by the application will be translated to mouse events instead.
          // This attribute is enabled by default. This value was added in Qt 5.7.
          QCoreApplication::setAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents, false);
      
      // log
      Form eventFilter1: QTabletEvent(TabletMove, deviceType=Stylus, pointerType=Pen, uniqueId=-838855321, pos=QPointF(24.3694,428.29), z=0, xTilt=0, yTilt=0, NoButton, pressure=0 isAccepted= false
      Form eventFilter2: QTabletEvent(TabletMove, deviceType=Stylus, pointerType=Pen, uniqueId=-838855321, pos=QPointF(24.3694,428.29), z=0, xTilt=0, yTilt=0, NoButton, pressure=0
      Form::event= QTabletEvent(TabletMove, deviceType=Stylus, pointerType=Pen, uniqueId=-838855321, pos=QPointF(24.3694,428.29), z=0, xTilt=0, yTilt=0, NoButton, pressure=0
      Form eventFilter1: QMouseEvent(MouseMove, localPos=24,428, screenPos=704,823) isAccepted= true
      Form eventFilter2  QMouseEvent(MouseMove, localPos=24,428, screenPos=704,823) source= Qt::MouseEventNotSynthesized
      Form::event= QMouseEvent(MouseMove, localPos=24,428, screenPos=704,823)
      
      
      

       

       

      Attachments

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

        Activity

          People

            owolff Oliver Wolff
            gao.xiangyang GAO XIANGYANG
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes