Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MenuBar from Qt.labs.platform
Forum Updated to NodeBB v4.3 + New Features

MenuBar from Qt.labs.platform

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 859 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I tried using the Qt labs platform menubar, but the following test application does not show a menu:

    import QtQuick 2.12
    import QtQuick.Window 2.10
    import Qt.labs.platform 1.0 as Platform
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Platform.MenuBar {
            id: menuBar
            Platform.Menu {
                id: fileMenu
                title: qsTr("File")
                // ...
    
                Platform.MenuItem {
                    text: qsTr("Zoom In")
                    shortcut: StandardKey.ZoomIn
                    onTriggered: zoomIn()
                }
            }
    
            Platform.Menu {
                id: editMenu
                title: qsTr("&Edit")
                // ...
            }
    
            Platform.Menu {
                id: viewMenu
                title: qsTr("&View")
                // ...
            }
    
            Platform.Menu {
                id: helpMenu
                title: qsTr("&Help")
                // ...
            }
        }
    }
    

    0_1560845059840_menu.png

    What am I missing?

    1 Reply Last reply
    1
    • Pradeep P NP Offline
      Pradeep P NP Offline
      Pradeep P N
      wrote on last edited by
      #2

      Hi @maxwell31

      Did you notice the Application Output ? ( I tested on Qt 5.9.2 )

      This gives you the hint i feel.

      ERROR: No native Menu implementation available.
      Qt Labs Platform requires Qt Widgets on this setup.
      Add 'QT += widgets' to .pro and create QApplication in main().
      

      All the best

      Pradeep Nimbalkar.
      Upvote the answer(s) that helped you to solve the issue...
      Keep code clean.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Hm, I did not get such an error message, using Qt 5.12 and 5.13. also adding widgets did not change anything

        1 Reply Last reply
        1
        • Pradeep P NP Offline
          Pradeep P NP Offline
          Pradeep P N
          wrote on last edited by Pradeep P N
          #4

          Hi @maxwell31

          • create QApplication in main().

          If my guess is right your main.cpp has QGuiApplication, you need to change it to QApplication to support Qt Labs Platform.

          On Android: (As MenuBar is currently available on macOS, Android & Linux Desktop only)

          0_1560917780357_c81c4252-f9ba-4374-96d7-77005638b723-image.png

          All the best.

          Pradeep Nimbalkar.
          Upvote the answer(s) that helped you to solve the issue...
          Keep code clean.

          1 Reply Last reply
          2
          • V Offline
            V Offline
            valera.gv
            wrote on last edited by valera.gv
            #5

            I confirm the same problem MenuBar with QT 5.12.7 QT Labs Platform Experimental 1.1 under linux CentOS 7 (+last updates). I tried to use unsuccessfully: QT+=widgets & QApplication & with/without QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar).
            But the qml control FileDialog perfect works as system FileDialog as widget FileDialog (Qt::AA_DontUseNativeDialogs).

            PS Under the windows ( qt 5.13 ) it works fine.

            PPS main.qml:

            import QtQuick 2.12
            import QtQuick.Window 2.12
            import QtQuick.Controls 2.12
            import QtQuick.Layouts 1.12
            
            import QtQuick.Dialogs 1.3 as OldDialogs
            import Qt.labs.platform 1.1
            import Qt.labs.settings 1.1
            import "qrc:/../3rdparty/controls"
            
            ApplicationWindow {
                visible: true
                width: 1024
                height: 600
                minimumWidth: 400
                minimumHeight: 200
            ...
                MenuBar {
                    Menu {
                        title: qsTr("&File")
                        Menu {
                            title: qsTr("&New")
            ...
               FileDialog {
                    fileMode: FileDialog.OpenFile
            ...
            

            The solution: Do not use Qt labs anymore :-///

            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