Results 1 to 5 of 5

Thread: QTableWidget - scrolling to bottom of the table

  1. #1
    Join Date
    Nov 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget - scrolling to bottom of the table

    I'm having this problem with scrolling to the bottom of my QTableWidget.
    I want the scroll bar to stay at the bottom as the table grows if the scroll bar is at the bottom to begin with.
    But when I call scrollToBottom(), the scroll bar moves only to the beginning of the last row inserted which is not always necessarily the bottom of the table because sometimes the height of the last row inserted is really large, how can I make the scroll bar move all the way to the bottom and not scroll to the last row in the table?

    here's my code:

    int max_slider_pos = table->verticalScrollBar()->maximum();
    bool move_slider_to_bottom = false;

    if(table->verticalScrollBar()->sliderPosition() == max_slider_pos)
    {
    move_slider_to_bottom = true;
    }

    // insert new row here

    table->resizeRowsToContents();

    table->resizeColumnsToContents();

    if(move_slider_to_bottom)
    {
    table->scrollToBottom();
    }

    Thanks for the help!
    Last edited by mkhoang; 11th November 2008 at 00:25.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget - scrolling to bottom of the table


  3. #3
    Join Date
    Nov 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget - scrolling to bottom of the table

    I do use scrollToBottom, as I mentioned in my first post, but it doesn't work well for me because some of my row heights are pretty large

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget - scrolling to bottom of the table

    How about
    Qt Code:
    1. table->verticalScrollBar()->setSliderPosition (table->verticalScrollBar()->maximum())
    To copy to clipboard, switch view to plain text mode 
    instead of scrollToBottom()?


    Ginsengelf

  5. #5
    Join Date
    Nov 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget - scrolling to bottom of the table

    yeah, i tried that too, ends up doing the same thing as scrollToBottom()

Similar Threads

  1. Replies: 3
    Last Post: 20th January 2011, 14:24
  2. scrolling in QTableWidget
    By Ursa in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2007, 08:22

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.