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. Custom control with different size rectangle
Forum Updated to NodeBB v4.3 + New Features

Custom control with different size rectangle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 251 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.
  • M Offline
    M Offline
    Makarand_EB
    wrote on last edited by
    #1

    control.png
    I want to implement one control with 7 layers of rectangle. Top and bottom 2 rectangles are of the same size. But middle 3 rectangles are 1/3rd of width of the top and bottom 2 rectangles also two of such sets.

    How can it be achieved using the minimal code in QML. ( i.e. with 1 repeater or nested repeaters ?)

    I designed it using repetitive code by simply adding 10 rectangles and anchoring them properly but its not a good practice when things can be done with repeater / model.

    ODБOïO 1 Reply Last reply
    0
    • M Makarand_EB

      control.png
      I want to implement one control with 7 layers of rectangle. Top and bottom 2 rectangles are of the same size. But middle 3 rectangles are 1/3rd of width of the top and bottom 2 rectangles also two of such sets.

      How can it be achieved using the minimal code in QML. ( i.e. with 1 repeater or nested repeaters ?)

      I designed it using repetitive code by simply adding 10 rectangles and anchoring them properly but its not a good practice when things can be done with repeater / model.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @Makarand_EB

      GridLayout{
              anchors.fill: parent
              columns : 3
              Repeater{
                  model: 13
                  Rectangle{
                      Layout.fillHeight: true
                      Layout.fillWidth: true
                      border.width: 1
                      Layout.columnSpan: index===0||index===1||index===11||index===12 ? 3 : 1
                      opacity : index===3||index===6||index===9 ? 0 : 1
                  }
              }
          }
      
      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