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

When the touch screen position and the menu item overlap, a second click-like situation occurs

    XMLWordPrintable

Details

    • Linux/X11

    Description

      I'm currently experiencing a problem:

      #include <QApplication>
      #include <QWidget>
      #include <QMenu>
      #include <QDebug
      #include <QGuiApplication> #include <QGuiApplication
      #include <QStyleHints
      #include <QContextMenuEvent
      
      class DebugWidget : public QWidget {
      public.
          explicit DebugWidget(QWidget *parent = nullptr) : QWidget(parent) {
              setContextMenuPolicy(Qt::CustomContextMenu);
              connect(this, &QWidget::customContextMenuRequested, [this](const QPoint &pos){
                  QMenu menu(this);
                  for(int i = 0; i < 30; i++) {
                      QAction *action = menu.addAction(QString(“Test %1”).arg(i + 1));
                      connect(action, &QAction::triggered, [action]
      
      {                     qWarning() << “Clicked action:” << action->text();                 }
      
      );
                  }
                  menu.exec(mapToGlobal(pos)); }
              });
          }
      
      protected.
          void contextMenuEvent(QContextMenuEvent *event) override
      
      {         qWarning() << “Context menu triggered by:”                    << (event->reason() == QContextMenuEvent::Mouse ? “Mouse” : ‘Touch’);         QWidget::contextMenuEvent(event);     }
      
      };
      
      int main(int argc, char *argv[])
      
      {     QApplication app(argc, argv);     DebugWidget w.     w.show(); return app.     return app.exec(); }
      

      Here's my demo for the current scenario:
      1. The Qt environment I'm using is 5.15, I call out the context menu by touching the screen and long-pressing, when the area of the touch screen happens to be on the options of the context menu, there will be a bug, that is, when I release the touch screen, I will select the current position of the menu options, which will result in a situation similar to the “second click”. 

       

      (When using the mouse, when clicking the right mouse button to call out the menu, click not release the mouse to move to the right menu of the corresponding item area when you release the right button will also trigger triggerd, but because the mouse to release the right button will not happen to overlap with the menu options, is the need to move a little bit will be hover after triggerd, so there is no problem, and the use of the touch screen, because the When using touchscreen, because the touchupdate is updated very frequently, so the finger touch screen slightly different strength will trigger the menu item hover, I feel this is not right.)

       

       

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              tsl115 Shilin Tian
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes