Results 1 to 8 of 8

Thread: ListView in a ScrollView: How to know scroll position (is it at bottom?)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Apr 2013
    Posts
    61
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ListView in a ScrollView: How to know scroll position (is it at bottom?)

    Hi,

    I have tried with 'atYEnd' in several property changes, to detect if scroll is at bottom or not

    It seems to work, and then I use that in 'onCountChanged' to put (or not) the scroll at the bottom

    That works once all the ListView height is full of messages, but NOT in ONE case: when the incoming message is the one that fills the
    ListView height (1st time that contentY is NOT '0').

    I don't know if it is clear...

    I have simplified my code to test (including the delegate), and now it seems like that:

    Qt Code:
    1. FocusScope {
    2. clip: true
    3.  
    4. id: focusScopeView
    5.  
    6. width: parent.width; height: parent.height
    7.  
    8. ScrollView {
    9.  
    10. width: parent.width; height: parent.height
    11.  
    12. ListView {
    13. id: listTexts
    14.  
    15. width: parent.width; height: parent.height
    16.  
    17. property bool bScrolled: false
    18.  
    19. model: textsModel
    20. delegate: Text { text: "Text:\t" + eventText }
    21.  
    22. onCountChanged: {
    23.  
    24. if (!bScrolled)
    25. positionViewAtEnd();
    26. }
    27.  
    28. onContentYChanged: {
    29. bScrolled = !atYEnd;
    30.  
    31. if (atYEnd)
    32. positionViewAtEnd()
    33. }
    34.  
    35. onContentHeightChanged: {
    36. if (!bScrolled)
    37. positionViewAtEnd();
    38. }
    39. }
    40. }
    41. }
    To copy to clipboard, switch view to plain text mode 

    Thanks and regards!

    Diego
    Last edited by ddonate; 24th June 2016 at 08:40.

Similar Threads

  1. Replies: 13
    Last Post: 4th August 2021, 16:47
  2. Replies: 0
    Last Post: 7th February 2015, 16:01
  3. QPlainTextEdit scroll to bottom
    By vrltwe in forum Newbie
    Replies: 1
    Last Post: 15th August 2014, 21:44
  4. Replies: 0
    Last Post: 30th January 2014, 13:35
  5. Replies: 1
    Last Post: 29th September 2011, 07:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.