Menus are unable to popup when using the Material theme in QtQuick
-
Hello everybody.
I noticed a strange bug when using the Material theme.I can open my custom context menu created using a MouseArea and a Menu with the help of a timer that triggers when the users holds a widget for 500 milliseconds (The main targets here are android phones that don't have the right-clicking functionality when using the touch screen). But that only works once when I use the Material theme.The normal theme is OK though.I created a demo and set the theme via
QQuickStyle::setStyle("Material");
and created a button like this:import QtQuick 2.14 import QtQuick.Window 2.14 import QtQuick.Controls 2.5 import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Material 2.3 ApplicationWindow{ ... ... Button{ id:btn1 width: 100 height: 100 anchors.left: parent.left text: "Click me!" MouseArea { id:mA anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) contextMenu.popup() } Timer{ id:cttimer repeat: false running: false interval: 500 onTriggered: { contextMenu.popup(mA.mouseX , mA.mouseY) console.log("Timer triggered") } } onPressedChanged: { if(pressed){ cttimer.running = true console.log("pressed") }else{ cttimer.running = false console.log("released") } } Menu { id: contextMenu MenuItem { text: "Cut" ; checkable: true} MenuSeparator{} MenuItem { text: "Copy" } MenuItem { text: "Paste" } ... ...
And please take a look at this video to see the interactions with that button.That situation is reproducible in android too.
The timer works correctly and gets triggered when I long-hold the button but the menu doesn't get popup after the first attempt.
I use Qt 5.14.2.Any idea?
Thanks in advance.