Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems with touch and hold events
Forum Updated to NodeBB v4.3 + New Features

Problems with touch and hold events

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 559 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    volkerd
    wrote on last edited by
    #1

    Hi,

    I am currently developing a HMI program (basically a simple browser) that is planned to be executed on a Windows 7 embedded system with touch screen. The program is based on the simple browser example, where I have thrown out all code that is related to tabbed widgets, find&replace functions, etc.

    My developing PC runs
    Windows 10
    QtCreator 4.15
    and I build the program with Qt 5.15.2 (Msvc2017, 32bit)

    The target PC is a panel PC with build in touch screen and runs Windows Embedded Standard.

    A requirement is that the user can touch and hold a button on the displayed web site to execute a function in the controlled system. This works when using a normal mouse, but when using the touch screen the long touch events are interpreted as right click events. I have tried to disable the touch and hold settings in Windows of the target system, to no avail (a quick internet search showed that this seems to a problem in Windows Embedded Standard...).

    So my idea was to overlay the QWebEngineView with a transparent QLabel which shall capture all mouse and touch events, install an event filter on it and modify all relevant events accordingly to filter out context menu events and then forward the events via sendEvent() to the view:

    
    bool BrowserWindow::eventFilter(QObject *object, QEvent *event) {
      qDebug() << __FUNCTION__ << object << event;
      if (object == m_overlay) {
        switch (event->type()) {
        case QEvent::ContextMenu:
          qDebug() << "Ignore context menu event";
          break;
    
        default:
          if (event->type() == QEvent::MouseButtonPress ||
              event->type() == QEvent::MouseButtonRelease) {
            QMouseEvent *e = static_cast<QMouseEvent *>(event);
    
            m_overlay->setText(
                QString("Mouse Event: %1 - %2").arg(e->buttons()).arg(e->source()));
          }
          qDebug() << "Send event to children of " << m_webViewWidget->webView()
                   << ":" << m_webViewWidget->webView()->children();
          for (auto *child : m_webViewWidget->webView()->children()) {
            qDebug() << "Send event to " << child << child->objectName();
            QApplication::sendEvent(child, event);
          }
          break;
        }
      }
      return false;
    }
    

    The overlay is instantiated and added to the layout like this:

    m_overlay = new QLabel(this);
    m_overlay->setStyleSheet("background:#aaaaaaaa");
    m_overlay->setGeometry(m_webViewWidget->webView()->geometry());
    m_overlay->setText("Label");
    m_overlay->lower();
    m_overlay->installEventFilter(this);
    m_stackedLayout = new QGridLayout(this);
    m_stackedLayout->addWidget(m_webViewWidget->webView(), 0, 0);
    m_stackedLayout->addWidget(m_overlay, 0, 0);
    

    Again, this works as planned for "regular" mouse events. But unfortunately not for events originating from the touch device. I can see from the debug output that the events are recognized and also send to the view of the web page, but the web page does simply not react to mouse clicks. The only difference I could detect is the source of mouse events for the touch events is "MouseEventSynthesizedBySystem".

    Here the debug output when using the mouse:
    The mouse press sequence starts in line 9 until line 25, thereafter the corresponding mouse release event.
    16ed8ba1-b2a2-4dda-81ea-2298b8787002-image.png

    Here the debug output when using the touch device:
    Start of mouse press event in line 6 until line 18, thereafter corresponding release event.
    705ade1a-0d0e-454f-88fd-0e4095fdae80-image.png

    My question is if anybody knows how to get QWebEnginePage to accept the events that are send in the installFilter() routine when they derive from synthesized mouse events.

    Thanks,
    Volker

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved