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. Item in a Column, position problem
Forum Updated to NodeBB v4.3 + New Features

Item in a Column, position problem

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

    Hi all,
    I have a column like this:
    @
    ...
    ...
    Column
    {
    anchors.fill: parent
    Text
    {
    text: "aaaa"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    Text
    {
    text: "bbbb"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    Text
    {
    text: "cccc"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    }
    ...
    ...
    @

    and when running I get this:
    @
    aaaa
    bbbb
    cccc
    @

    now if I use Item:
    @
    ...
    ...
    Column
    {
    anchors.fill: parent
    Text
    {
    text: "aaaa"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    Text
    {
    text: "bbbb"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    Item
    {
    Text
    {
    text: "cccc"
    anchors.horizontalCenter: parent.horizontalCenter
    }
    }
    }
    ...
    ...
    @

    I get:

    @
    aaaa
    bbbb
    @
    and "cccc" is over "aaaa" .

    It seems like "cccc" isn't positioned after "bbbb" in the column.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on last edited by
      #2

      Now I tried with:
      @
      ...
      ...
      Column
      {
      anchors.fill: parent
      Text
      {
      id: aaaa
      text: "aaaa"
      anchors.horizontalCenter: parent.horizontalCenter
      }
      Text
      {
      id: bbbb
      text: "bbbb"
      anchors.horizontalCenter: parent.horizontalCenter
      }
      Item
      {
      width: parent.width
      height: bbbb.height
      Text
      {
      text: "cccc"
      anchors.horizontalCenter: parent.horizontalCenter
      }
      }
      }
      ...
      ...

      @

      and I get the right column:
      @
      aaaa
      bbbb
      cccc
      @

      should it be a bug?

      1 Reply Last reply
      0
      • X Offline
        X Offline
        X-Krys
        wrote on last edited by
        #3

        I had this issue too, and its looks like a bug for me since even if the size of the third item is 0 in your first example it should be positioned just after "bbbb".

        Here is another example that demonstrates this bug :
        @
        ...
        ...
        Column
        {
        anchors.fill: parent
        Text
        {
        text: "aaaa"
        anchors.horizontalCenter: parent.horizontalCenter
        }
        Item
        {
        Text
        {
        text: "bbbb"
        anchors.horizontalCenter: parent.horizontalCenter
        }
        }
        Text
        {
        text: "cccc"
        anchors.horizontalCenter: parent.horizontalCenter
        }
        }
        ...
        ...
        @

        The behavior will be : "bbbb" over "aaaa"
        But I would expect it to be : "bbbb" after "aaaa" and under "cccc"

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jackyang
          wrote on last edited by
          #4

          I don't think it is a bug.
          The Item inside the Column doesn't give it the width and height. So x, y of Item should be aligned with Column's. The Item's child Text anchors to its parent, but the parent doesn't has a width size to let it be on the center of parent's width.
          So the resolve will be like below :
          @
          bb aaaa
          cccc
          @
          Text element of bbbb present wrong size and wrong position.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            luca
            wrote on last edited by
            #5

            [quote author="jackyang" date="1324518350"]I don't think it is a bug.
            The Item inside the Column doesn't give it the width and height. So x, y of Item should be aligned with Column's. The Item's child Text anchors to its parent, but the parent doesn't has a width size to let it be on the center of parent's width.
            So the resolve will be like below :
            @
            bb aaaa
            cccc
            @
            Text element of bbbb present wrong size and wrong position.[/quote]

            Why doesn't Item take its child size?

            1 Reply Last reply
            0
            • X Offline
              X Offline
              X-Krys
              wrote on last edited by
              #6

              [quote author="jackyang" date="1324518350"]I don't think it is a bug.
              The Item inside the Column doesn't give it the width and height. So x, y of Item should be aligned with Column's. The Item's child Text anchors to its parent, but the parent doesn't has a width size to let it be on the center of parent's width.
              So the resolve will be like below :
              @
              bb aaaa
              cccc
              @
              Text element of bbbb present wrong size and wrong position.[/quote]

              I agree for the horizontal alignment but I think the problem here is just relative to the positionning on the vertical axe. So even it the Item doesn't have a height size it should positioned like:

              @
              aaaa
              bb cccc
              @

              1 Reply Last reply
              0
              • X Offline
                X Offline
                X-Krys
                wrote on last edited by
                #7

                [quote author="Luca" date="1324540304"]
                [quote author="jackyang" date="1324518350"]I don't think it is a bug.
                The Item inside the Column doesn't give it the width and height. So x, y of Item should be aligned with Column's. The Item's child Text anchors to its parent, but the parent doesn't has a width size to let it be on the center of parent's width.
                So the resolve will be like below :
                @
                bb aaaa
                cccc
                @
                Text element of bbbb present wrong size and wrong position.[/quote]

                Why doesn't Item take its child size?
                [/quote]

                The size of an Item and its contents is not linked by default.

                You can achieve this with the childrenRect property like that :

                @
                ...

                            Item
                            {
                                width: childrenRect.width
                                height: childrenRect.height
                
                                Text
                                {
                                    text: "bbbb"
                                }
                            }
                

                ...
                @

                The size of the item is then bound to the size of its content.

                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