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. Error adding a Menu in QML

Error adding a Menu in QML

Scheduled Pinned Locked Moved QML and Qt Quick
qml
2 Posts 2 Posters 651 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Chila
    wrote on last edited by A Former User
    #1

    I have the following code:

    import QtQuick 2.4
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import QtQuick.Controls 1.4
    
    ApplicationWindow {
        title: qsTr("Hello World!")
        width: 640
        height: 480
        visible: true
    
        menuBar: MenuBar {
            id: menuBar
        }
    
        MouseArea
        {
            anchors.fill: parent
            onClicked: { menuBar.menus.addItem("test") }
        }
    }
    

    When I run it and click, the following message appears:

    qrc:/main.qml:19: TypeError: Property 'addItem' of object [object Object] is not a function
    

    Why is this?

    1 Reply Last reply
    0
    • timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      This one is discussed on http://stackoverflow.com/questions/32142565/error-adding-a-menu-in-qml ; there's some stuff there on how hard (impossible?) it is to dynamically add a Menu to a MenuBar, but maybe we're both missing some other trick.

      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