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. Labs Menubar not working properly
Forum Updated to NodeBB v4.3 + New Features

Labs Menubar not working properly

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 418 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.
  • J Offline
    J Offline
    jeffB100
    wrote on last edited by
    #1

    Hi all

    I've followed all of the instructions I can find including:
    Using "QApplication" instead of "QGuiApplication" in main.cpp
    "QT += widgets" in .pro file
    (As a side note I get the same results whether I do the above or not - because I'm on macOS)
    "import Qt.labs.platform 1.1 as Labs" in main.qml

    Here's the code in my main.qml

    Window {
        id: window
        visible: true
        visibility: "Maximized"
        width: 900
        minimumWidth: 900
        height: 700
        minimumHeight: 700
        title: qsTr("Crop Face")
    
    // Below taken straight from documentation
        Labs.MenuBar {
            id: menuBar
    
            Labs.Menu {
                id: editMenu
                title: qsTr("&Edit")
                // ...
            }
    
            Labs.Menu {
                id: viewMenu
                title: qsTr("&View")
                // ...
            }
    
            Labs.Menu {
                id: helpMenu
                title: qsTr("&Help")
                // ...
            }
        }
    

    And I get this result:

    Menu error.png

    and

    Menu error Emoji.png

    Where on earth is "Emoji & Symbols" coming from !?
    I have a commercial license and am using Qt 5.13 on MacOS Mojave.
    Interestingly if I change title: qsTr("&Edit") to title: qsTr("&Hi"), I don't get a Hi menu.
    Is there something I'm doing wrong or does Labs Menubar and Menu simply not work.
    If they don't work, how do I create a standard Mac native platform menubar?

    Thanks
    Jeff

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jeffB100
      wrote on last edited by
      #2

      Turns out at least one menuItem is required in a Menu for the menu to show up. Because "Emoji & Symbols" is added to Edit automatically by Mac, the Edit menu does show up, but none of the others do.
      I've added my new code below that works fine. Also note that because the "About" menuItem normally shows up under the application Menu, that is where it is placed and because that's the only menuItem in the File menu, the File menu doesn't need to show up. (This is how it should be - see image after code.)

      ApplicationWindow {
          id: window
          visible: true
          visibility: "Maximized"
          width: 900
          minimumWidth: 900
          height: 700
          minimumHeight: 700
          title: qsTr("Crop Face")
      
      
          Labs.MenuBar {
              id: menuBar
      
              Labs.Menu {
                  id: fileMenu
                  title: qsTr("File")
      
                  Labs.MenuItem {
                      text: qsTr("&About")
                     // onTriggered: Qt.quit()
                  }
              }
      
              Labs.Menu {
                  id: windowMenu
                  title: qsTr("&Window")
      
                  Labs.MenuItem {
                      text: qsTr("&Minimize")
                      //onTriggered: messageDialog.show(qsTr("Open action triggered"))
                  }
                  Labs.MenuSeparator{}
                  Labs.MenuItem {
                      text: qsTr("Scroll Up")
                      //onTriggered: messageDialog.show(qsTr("Open action triggered"))
                  }
                  Labs.MenuItem {
                      text: qsTr("Scroll Down")
                      //onTriggered: messageDialog.show(qsTr("Open action triggered"))
                  }
              }
      
      
      
              Labs.Menu {
                  id: helpMenu
                  title: qsTr("&Help")
                  Labs.MenuItem {
                      text: qsTr("&View Website")
                      //onTriggered: messageDialog.show(qsTr("Open action triggered"))
                  }
              }
          }
      

      Menu Correct.png

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved