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. [SOLVED] ListView with populate transition
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] ListView with populate transition

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

    Hello,

    i try to create a ListView with a populate transition.
    to keep it simple:
    @
    ListView {
    anchors.fill: parent
    model: ListModel {
    id: modelData
    ListElement {
    name: "Bill Smith"
    number: "555 3264"
    }
    ListElement {
    name: "John Brown"
    number: "555 8426"
    }
    ListElement {
    name: "Sam Wise"
    number: "555 0473"
    }
    }
    delegate: Rectangle {
    height: 44
    width: 200
    opacity: 0
    Text {
    anchors.centerIn: parent
    text: name
    }
    }
    populate: Transition {
    NumberAnimation { property: "opacity"; to: 1.0; duration: 1000 }
    }
    }
    }
    @

    So what's happen here is all my items are at position 0,0. It doesn't madder what kind of Animation i did. All items are on the same position. Someone an idea?

    **Sorry for my english :)

    PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Are you using Window component as root element ? I too had came across this issue earlier and ended up using Item instead of Window.

      157

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dasRicardo
        wrote on last edited by
        #3

        First, Thx for your reply. I'm don't rely understand what u mean because i had an qt quick application so i need th Application Window as root?
        Here my Full source.

        @
        ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")

        Rectangle {
          anchors.fill: parent
          color: '#ff0000'
          ListView {
            anchors.fill: parent
            model: ListModel {
              id: modelData
              ListElement {
                  name: "Bill Smith"
                  number: "555 3264"
              }
              ListElement {
                  name: "John Brown"
                  number: "555 8426"
              }
              ListElement {
                  name: "Sam Wise"
                  number: "555 0473"
              }
            }
            delegate: Rectangle {
              height: 44
              width: 200
              opacity: 0
              Text {
                anchors.centerIn: parent
                text: name
              }
            }
            populate: Transition {
                NumberAnimation { property: "opacity"; to: 1.0; duration: 1000 }
            }
          }
        }
        

        }
        @

        **Sorry for my english :)

        PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Ok.. That was a long time back. I usually use Item as root. Now after looking into this it seems that anchors.fill: parent for ListView is failing here. Try setting width and height to Rectangle or ListView.

          Edited

          157

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dasRicardo
            wrote on last edited by
            #5

            Yes, it works but why??? Sounds totally stupid. It's a bug?

            **Sorry for my english :)

            PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              May be. It seems in that hierarchy ListView is not able to get the parent's width and height. Setting Width and Height to either one makes it work.
              Edited previous post.

              157

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dasRicardo
                wrote on last edited by
                #7

                The problem here set width and height make it difficult to automatically change size of the child. I know i can listen on onWidthChanged and onHeightChanged but the documentation always said "USE ACNHORS" :) so for me it's a but. I Fix it dirty. I initialize the Rectangle with a width and height and set in an Component.onComplete call the anchors.fill property. But it's a nasty workaround a think. I set the thread to solved because the main problem is solved.

                THX for your help.

                **Sorry for my english :)

                PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

                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