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. Placing child elements in a component
Forum Updated to NodeBB v4.3 + New Features

Placing child elements in a component

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.9k 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.
  • Y Offline
    Y Offline
    YetAnotherNick
    wrote on last edited by
    #1

    Is there some way in a component to specify where should the child items be placed?

    I mean something like:

    main.qml:
    @import Qt 4.7

    MyComponent {
    Image { id: coolpic; source: "pic.jpg" }
    }@

    MyComponent.qml:
    @import Qt 4.7

    Rectangle {
    border.color: "black"

    Rectangle {
        color: "white"
        anchors.margins: 3
    
        // placeholder for the children (e.g. the coolpic Image element)
    }
    
    // some other items here
    

    }@

    1 Reply Last reply
    0
    • P Offline
      P Offline
      parancibia
      wrote on last edited by
      #2

      try this

      @
      import Qt 4.7

      default property alias content: content.children

      Rectangle {
      border.color: "black"

      Rectangle {
          id: content
          color: "white"
          anchors.margins: 3
      
          // placeholder for the children (e.g. the coolpic Image element)
      }
      
      // some other items here
      

      }
      @

      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