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. children vs childrenRect
Forum Updated to NodeBB v4.3 + New Features

children vs childrenRect

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 1.7k 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.
  • V Offline
    V Offline
    Vinoth Rajendran4
    wrote on last edited by
    #1

    Hi All,
    I have a scenario where i need to bind the parent item's height to its children height , sample code for understanding

    Item {
         width: 300
         height: children.height // or childrenRect.height
    
        Item{
           .............
        }
        Item{
            ........... 
        }
    }
    

    I need to know which is the best way to bind, either to use children.height or childrenRect.height and please explain the reason for the choice.

    Any help is appreciated.

    Thanks!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Is this for real? Have you even tried it?

      children is a list of items. It does not even have a height property!

      So obviously, the answer is: childrenRect.height.

      (Z(:^

      V 1 Reply Last reply
      1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        And that's not the best way to accomplish this.

        You should use positioners like Row or Column or layouts like ColumnLayout or RowLayout.
        If you don't want that for some reason, you should set the implicit size of your container from the implicit size of your items.
        I have yet to see a legit use-case of childrenRect.

        I guess you should better define what you want from a higher level point of view.

        Item {
            width: 300
            Item{
               .............
            }
            Item{
                ........... 
            }
        }
        

        Do you want both child item to be side by side? Stacked on top of eachother?
        Do you want to position them manually?

        V 1 Reply Last reply
        3
        • sierdzioS sierdzio

          Is this for real? Have you even tried it?

          children is a list of items. It does not even have a height property!

          So obviously, the answer is: childrenRect.height.

          V Offline
          V Offline
          Vinoth Rajendran4
          wrote on last edited by
          #4

          @sierdzio , I was using children.height in my project. As you mentioned, I dig deeper and its a wrong approach which i have used in my project sometime.

          Thanks for the info.

          1 Reply Last reply
          0
          • GrecKoG GrecKo

            And that's not the best way to accomplish this.

            You should use positioners like Row or Column or layouts like ColumnLayout or RowLayout.
            If you don't want that for some reason, you should set the implicit size of your container from the implicit size of your items.
            I have yet to see a legit use-case of childrenRect.

            I guess you should better define what you want from a higher level point of view.

            Item {
                width: 300
                Item{
                   .............
                }
                Item{
                    ........... 
                }
            }
            

            Do you want both child item to be side by side? Stacked on top of eachother?
            Do you want to position them manually?

            V Offline
            V Offline
            Vinoth Rajendran4
            wrote on last edited by
            #5

            @GrecKo , I want all my child items to be placed side by side.

            sierdzioS 1 Reply Last reply
            0
            • V Vinoth Rajendran4

              @GrecKo , I want all my child items to be placed side by side.

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @Vinoth-Rajendran4 said in children vs childrenRect:

              @GrecKo , I want all my child items to be placed side by side.

              In that case you should use Row or RowLayout.

              (Z(:^

              1 Reply Last reply
              2

              • Login

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