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. Equivalent to AlignBottom for ListView?
Forum Updated to NodeBB v4.3 + New Features

Equivalent to AlignBottom for ListView?

Scheduled Pinned Locked Moved QML and Qt Quick
13 Posts 5 Posters 5.8k 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.
  • Q Offline
    Q Offline
    qgil
    wrote on last edited by
    #1

    Hi, there is this ListView nurtured by a dynamic model that, ideally, should start placing the items in the bottom, piling them up as soon as there is more. In the ListView docs there is a mention to ListView.Vertical, but apparently it is assumed that the list will always grow from top to bottom. Looking at Flickable or Item docs I couldn't find anything either.

    Is there a way to obtain a behavior similar to Text's "verticalAlignment: Text.AlignBottom"?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      You could use a blank item the height of your viewable area as your ListView::header to pad downward, append to your model, and then call ListView::positionViewAtEnd().

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qgil
        wrote on last edited by
        #3

        Wow, I hadn't thought of solving this problem this way. Thank you!

        Now... I'm still stuck in the implementation since I'm quite new to applying methods. The header is fine, but I must be doing something with the function because the items still are listed from top to bottom. This is the basic structure of the code, see the attempts of adding the function at the end:

        @
        Page {
        id: ficsSeekGame
        ...

        Rectangle {
            id: seekListWindow
        

        ...

            ListView {
                id: seekList
                header: seekListHeader 
                model: gameAdvertisements
                delegate:
        
                    Item {
                    id: listItem
        
                    Rectangle {
                        id: gameData
        

        ...
        }

                        MouseArea {
                            id: mouseArea
                            anchors.fill: parent
                            onClicked: {
                                confirmGame.open();
                            }
        

        ...
        }
        }
        }
        }
        }

        Component {
            id: seekListHeader
        }
        

        ...

        // Component.onCompleted: positionViewAtEnd() why this doesn't work?
        // Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning) this doesn't work either?
        

        ...
        }@

        fwiw you can see this code in context at http://gitorious.org/miniature/miniature/blobs/master/src/frontend/SeekGame.qml

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mikhas
          wrote on last edited by
          #4

          From #qt-qml:

          <mikhas> hey, having a problem with ListView's
          appending items to it, and the moment the items are out of the visible area, the signal handlers such as ListView.onAdd dont get called any more
          <special> mikhas: that's expected; ListView only creates delegates for visible items (and a small buffer that might be visible soon).
          <mikhas> …
          <special> If you want to react to additions, connect to the signals of the model
          <mikhas> ok
          <mikhas> special, hm, and how? I mean, what is the type of a model in a ListView?
          <special> is your model a QAbstactItemModel?
          <mikhas> yes
          otherwise, I cant dynamically append things
          <special> right; then you can use something like Connections { target: view.model; onRowsInserted: console.log(start, end) }
          <mikhas> ok
          would be nice if that was to be found in the docs
          current ListView doc doesnt mention those details
          like, a ListView signal not being emitted because of delegates only being created for visible range
          <special> technically, it's not a ListView signal; it's an attached signal on the delegate from ListView
          <mikhas> special, works
          really, this should be in docs
          it was not clear to me why such useful looking function such as ListView.positionAtEnd wouldnt work

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mikhas
            wrote on last edited by
            #5

            But now it also repositions the view while we are trying to pan the view. What we eventually need is to disrupt that reposition handling upon manual panning, probably with a cooldown of some sort.

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qgil
              wrote on last edited by
              #6

              Thanks! Please upload the new version and I will keep fighting with these methods.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbrasser
                wrote on last edited by
                #7

                Hi,

                For reference, there is a suggestion for official support for this in the system (and it's something we'd like to implement), at "QTBUG-16376":https://bugreports.qt.nokia.com/browse/QTBUG-16376

                Regards,
                Michael

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qgil
                  wrote on last edited by
                  #8

                  Thanks for the pointer. Added my vote. :)

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    qgil
                    wrote on last edited by
                    #9

                    [quote author="mikhas" date="1313532737"]
                    really, this should be in docs
                    it was not clear to me why such useful looking function such as ListView.positionAtEnd wouldnt work[/quote]

                    A little contribution to the solution of this problem: http://developer.qt.nokia.com/doc/qt-4.7/qml-listview.html#comments

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #10

                      I think the comment could be more helpful, if it actually contained a bit of code that will make sure the newly added item becomes visible. Logging to console isn't going to help there.

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        qgil
                        wrote on last edited by
                        #11

                        This is my first note ever to the docs and I'm the non-expert in this thread. :) I just copy-pasted from the posts above thinking that anybody could edit the notes to improve them, like in a wiki (is this true or is this only limited to admins?). Sorry, I'm doing my best here. Thanks for your comments!

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          I did not mean to discourage you from contributing to the docs. However, if you have not come further than the code you posted yet, then perhaps the route will not even work. If I now just read the comment, I don't really see a solution, just a possible beginning of one.

                          I think that others can modify and improve on your comment. However, I would like to encourage you to further develop the comment as your solution becomes more complete.

                          Thanks for contributing your insights to the documentation!

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            qgil
                            wrote on last edited by
                            #13

                            I "posted":http://developer.qt.nokia.com/doc/qt-4.7/qml-listview.html#comments better example showing the code structure to follow and a link to the only "real example":http://gitorious.org/miniature/miniature/blobs/master/src/frontend/SeekGame.qml I have at hand today. I was able to test it today and see it working in our MeeGo Harmattan project and the N9. I guess a clean example without external dependencies would run just anywhere with Qt Quick.

                            Andre, thank you for your encouragement - and I mean this. :)

                            [EDIT: fixed link, Volker]

                            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