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. Menus are unable to popup when using the Material theme in QtQuick
Qt 6.11 is out! See what's new in the release blog

Menus are unable to popup when using the Material theme in QtQuick

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 234 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.
  • P Offline
    P Offline
    Parsa Mousavi
    wrote on last edited by Parsa Mousavi
    #1

    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.

    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