Results 1 to 5 of 5

Thread: Keeping focus at bottom of QListView

  1. #1
    Join Date
    Jan 2006
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Keeping focus at bottom of QListView

    I'm using QT 3.3.1 and have a main form that has a QListView that will continually have QListViewItems added to it with the top being the first one added and the bottom being the last one added. What I want to do is have the QListView stay at the bottom of the list. I've tried to use QListView::setCurrentItem on the last item, but that doesn't bring the QListView to the bottom, it just highlights the last QListViewItem. I've also tried to use QListView::ensureItemVisible, but after a few seconds, the refresh boggs down quite a bit to the point where the program essentially locks up. After taking a quick look at the code, it seems as though ::ensureItemVisible starts at the top and moves to the selected item and after getting a large number of items, this becomes horribly inefficient. Is there some sort of property that I can set that will cause the QListView to keep the scroll bar at the bottom of the list as things get added?

    If there's any needed information that I've forgotten to provide, please feel free to ask.

    Thanks in advance.

    PS - I posted this over at the old board as well because I was having login trouble over here. Sorry for the double posting if you read this here and there.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keeping focus at bottom of QListView

    QListView inherits QScrollView, so you might try QScrollView::scrollBy() or QScrollView::ensureVisible() together with QScrollView::contentsHeight ().

  3. #3
    Join Date
    Jan 2006
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keeping focus at bottom of QListView

    Quote Originally Posted by jacek
    QListView inherits QScrollView, so you might try QScrollView::scrollBy() or QScrollView::ensureVisible() together with QScrollView::contentsHeight ().
    Using QScrollView::scrollBy( ) along with QScrollView::contentsHeight( ) seemed to work the best. However, it still boggs down around 9000 or so children. I just wish there was a property that I could set that could automatically keep the scroll bar at the bottom. Thanks for your help.

  4. #4
    Join Date
    Jan 2006
    Location
    Sofia, Bulgaria
    Posts
    24
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Keeping focus at bottom of QListView

    another solution:
    if ( list_view->lastChild() )
    list_view->ensureItemVisible( list_view->lastChild() );

  5. #5
    Join Date
    Jan 2006
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keeping focus at bottom of QListView

    Quote Originally Posted by gadnio
    another solution:
    if ( list_view->lastChild() )
    list_view->ensureItemVisible( list_view->lastChild() );
    If you take a look at my initial post, I did try ::ensureItemVisible. However, that bogged down well before the 9000 children mark.

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.