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. ContentItem in custom item
Forum Updated to NodeBB v4.3 + New Features

ContentItem in custom item

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

    Hello all! I wonder what's correct way to implement contentItem property approach in my custom items.

    For example, I want to implement Button with the menu, so I have created ButtonMenu.qml with the following code:

    Button {
        id: root
        property alias menu: _menu
    
        onClicked: {
            _menu.open()
        }
    
        Menu {
            id: _menu
    	x: 0
    	y: root.height
        }
    }
    

    But I can not realize what is the correct and easy way without big and complex loops to add MenuItems in Menu or replace the whole Menu in the outer code while using my ButtonMenu.qml

    1 Reply Last reply
    0
    • S Offline
      S Offline
      St.Stanislav
      wrote on last edited by St.Stanislav
      #2

      Well, answer is coming after a question even one has googled before it a lot. In the case of using menu, contentData property can be used for the replacing MenuItem's. I think the same approach can be extended on custom types.

      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