[Interest] QML: Optional Menus in MenuBar

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Fri Aug 9 13:51:17 CEST 2013

On Aug 9, 2013, at 2:42 AM, Daiwei Li <daiweili at gmail.com<mailto:daiweili at gmail.com>> wrote:

Hi all,

I would like to be able to include Menus in my ApplcationWindow's MenuBar based on the platform. e.g.:

import QtQuick 2.1

import QtQuick.Controls 1.0

import QtQuick.Window 2.0

ApplicationWindow {

    title: qsTr("Hello World")

    width: 640

    height: 480

    menuBar: MenuBar {

        Menu {

            title: qsTr("File")

            visible: Qt.platform.os === "win"

            MenuItem {

                text: qsTr("Exit")

                onTriggered: Qt.quit();





Unfortunately, this example doesn't work (the menu is still there) because Menu.visible is ignored unless Menu is a submenu. Does anyone know how I can conditionally show a menu in the menubar?


I can confirm that this is indeed a bug and we are working on a fix for it.
We have created https://bugreports.qt-project.org/browse/QTBUG-32899 to track it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130809/5a603573/attachment.html>

More information about the Interest mailing list