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. QMenu flickering when opened by touch
Forum Updated to NodeBB v4.3 + New Features

QMenu flickering when opened by touch

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pbsurf
    wrote on last edited by
    #1

    I'm encountering an issue where a QToolButton menu is being quickly hidden and redisplayed in response to the first touch update after being opened by a touch begin. Stepping into the Qt source, it appears that when the touch begin event is translated to the mouse event which opens the menu, the global mouse button state is never updated properly, causing the first touch update to produce an erroneous mouse button press event. I'm using Qt 5.2 on Android, but it appears that it would happen with touch input on any platform. I've tried an event filter to reject the erroneous events but encountered the additional problem that an immediate touch end with no touch update doesn't generate a mouse button release event. Can anyone suggest a possible workaround?

    Minimal example to reproduce below:

    @
    #include <QtWidgets>

    // copy the following to qmenutest.pro:
    // SOURCES = main.cpp
    // TARGET = QMenuTouchTest
    // QT += widgets

    class MainWindow : public QMainWindow
    {
    public:
    MainWindow(QWidget* parent = 0) : QMainWindow(parent)
    {
    QMenu* menu = new QMenu;
    menu->addAction("Item 1");
    menu->addAction("Item 2");
    menu->addAction("Item 3");
    QToolBar* toolbar = new QToolBar;
    QAction* action = toolbar->addAction("Menu");
    action->setMenu(menu);
    QToolButton* toolbtn = qobject_cast<QToolButton*>(toolbar->widgetForAction(action));
    toolbtn->setPopupMode(QToolButton::InstantPopup);
    addToolBar(toolbar);
    setCentralWidget(new QLabel("QMenu Touch Test"));
    }
    };

    int main(int argc, char* argv[])
    {
    QApplication app(argc, argv);
    MainWindow window;
    window.show();
    return app.exec();
    }
    @

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pbsurf
      wrote on last edited by
      #2

      Just to follow up, reported here: https://bugreports.qt-project.org/browse/QTBUG-35985 and my workaround here: https://github.com/pbsurf/touchwidgets

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Thanks for sharing your findings and workaround !

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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