Results 1 to 3 of 3

Thread: QListView with conditional vertical automatic scroll

  1. #1
    Join Date
    Jul 2009
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QListView with conditional vertical automatic scroll

    I am trying to achieve a console like behaviour to a QListView where everytime the vertical scroll bar is set all the way to the bottom and a new item is added, scroll it so that the new item is visible.

    I came up with this piece of code put where every new item is added:

    Qt Code:
    1. if (QListView::verticalScrollBar()->value() == QListView::verticalScrollBar()->sliderPosition())
    2. {
    3. QListView::scrollToBottom();
    4. }
    To copy to clipboard, switch view to plain text mode 

    Problem is, even tho tracking is enabled on the QAbstractScrollBar widget, I always get value() and sliderPosition() with the same value making the QListView always scroll down.

    Is this the best way out of this? If not, what should be my solution? If it is, what am I missing that make those 2 values identical no matter what?

  2. The following user says thank you to jmesquita for this useful post:

    wendelmaques (6th January 2011)

  3. #2
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListView with conditional vertical automatic scroll

    you can accomplish last added item/row to be visible and scroll down automatically using the API
    Qt Code:
    1. setCurrentCell(row, colum)
    To copy to clipboard, switch view to plain text mode 

  4. #3
    Join Date
    Jul 2009
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView with conditional vertical automatic scroll

    Well, two problems there.

    1. setCurrentCell is a QTableWidget method, not a QListView method.
    2. Even tho there is an equivalent method for QListView, this does not solve the question at hand since the problem is not how to scroll the new item but how to check if the vertical scrollbar is rolled all the way to the bottom.

    This is still unsolved and I can't figure out why the condition as described on the first post always returns true.

    Regards,

    Mesquita

Similar Threads

  1. QListView scroll height (solved)
    By efegea in forum Qt Programming
    Replies: 0
    Last Post: 26th April 2009, 14:06
  2. Vertical scroll bar, but resizable horizontal content
    By minimoog in forum Qt Programming
    Replies: 0
    Last Post: 14th January 2009, 20:51
  3. vertical scroll bar in Qt box.
    By rajveer in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2008, 07:41
  4. Vertical Scroll Bar - Style Sheet
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2007, 19:03
  5. Automatic scroll in graphics view
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2006, 14:07

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.