Results 1 to 5 of 5

Thread: QTableWidget - scrolling to bottom of the table

Threaded View

Previous Post Previous Post   Next Post Next Post
  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; 10th November 2008 at 23:25.

Similar Threads

  1. Replies: 3
    Last Post: 20th January 2011, 13:24
  2. scrolling in QTableWidget
    By Ursa in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2007, 07: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.