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. [solved]Qt Quick Controls Scope
Forum Updated to NodeBB v4.3 + New Features

[solved]Qt Quick Controls Scope

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 901 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.
  • W Offline
    W Offline
    winkler3523
    wrote on 16 Apr 2014, 15:35 last edited by
    #1

    Hello,

    i have problems with the following code:
    @
    Rectangle {
    width: 360
    height: 360

    MenuManager {
        id: menu
    }
    
    
    ListView {
        anchors.fill: parent
        model: menu.activeMenu
    
        delegate: Rectangle {
            width: 360
            height: 360
    
            Button {
                anchors.fill parent
                text: "Back"
                onClicked: {
                    menu.MenuBack()  //<- dosen't work
                }
            }
    

    // MouseArea {
    // anchors.fill: parent
    // onClicked: {
    // menu.MenuBack() //<- works!
    // }
    // }
    }
    }
    }
    @

    When i use the MouseArea Element in the delegate i can call a function of the MenuManager Object. When i use a Button it dosen't work. In the Button's onClicked method menu is undefined.
    (The MenuManager Object is a c++ class. The methods are marked as Q_INVOKABLE, and the class is registerd via qmlRegisterType)

    Any ideas what's the reason for this behaviour?

    Thanks

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on 16 Apr 2014, 16:18 last edited by
      #2

      Button itself has a property named "menu". You use this to set a popup menu on the button. The scope rules will first look in the item itself for a property named menu before your menu name declaration is found. Just rename the menu manager to something else and it should work fine.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        winkler3523
        wrote on 16 Apr 2014, 16:26 last edited by
        #3

        Thanks,

        after the renaming of the property everything works.

        1 Reply Last reply
        0

        1/3

        16 Apr 2014, 15:35

        • Login

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