Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML ToolBarStyle hides Android Menu (Qt 5.5.1)



  • Here is basically some cut and paste QML from the documentation... an Application window with a MenuBar and a ToolBar. Run it for Desktop, it works fine. Run it on android it works fine (the menu bar is integrated on the right of the toolbar.) However, when I add the ToolBarStyle to change the background of the toolbar, the menu is gone under android. This has got to be something simple, I've tried a gazillion googles and different permutations, but no joy. Has anyone got a clue on this one?

    import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.Layouts 1.1
    import QtQuick.Controls.Styles 1.4
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        menuBar: MenuBar {
            Menu {
                title: qsTr("File")
                MenuItem {
                    text: qsTr("&Open")
                    onTriggered: console.log("Open action triggered")
                }
                MenuItem {
                    text: qsTr("Exit")
                    onTriggered: Qt.quit();
                }
                
            }
        }
        
        toolBar: ToolBar {
             // THIS STYLE CAUSES ANDROID MENU TO DISAPPEAR
            style: ToolBarStyle {
                background: Rectangle {
                   color: "green"
                }
            }
            RowLayout {
                anchors.fill: parent
                ToolButton {
                    text: "foo"
                }
            }
            
        }
       
        Label {
            text: qsTr("Hello World")
            anchors.centerIn: parent
        }
    }
    
    


  • ok this appears to be the same problem as this:
    https://forum.qt.io/topic/57647/qml-change-toolbar-color-one-style-property-only

    not really "solved", but at least some pointers in that previous post.