Results 1 to 3 of 3

Thread: Resizing window depending on QTableView

  1. #1
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Resizing window depending on QTableView

    Hi,

    I would like to make it so that my window increases in length as more rows are added to my QTableView widget.

    Currently when my program is run my QTableView is short along with my window, what I would like to happen is that when I add rows of data to the QTableView it would get longer, until the maximum size of the window is reached, then the vertical scroll-bar would appear in the QTableView widget, so more rows can be added but the window doesn't get any longer.

    Currently I am setting my window size with:
    Qt Code:
    1. Loader::setMinimumSize(600,400);
    2. Loader::setMaximumSize(600,800);
    To copy to clipboard, switch view to plain text mode 

    and at the moment, the vertical scroll-bar appears as soon as the number of rows exceeds the space shown in the QTableView widget, and I have to manually drag the window to make it vertically longer.

    I dont really want to start the window in its maximum size, and I would like to see as many rows as possible before the scroll-bar appears in the QTableView widget.


    I hope I described my problem effectively, thanks for any help.

  2. #2
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resizing window depending on QTableView

    Well I have found a solution, its not very elegant but it works okay...

    I count the number of rows added to the table, and when I get to a certain number of rows added, I start increasing the minimum length of the window with each additional row that is added (using setMinimumSize(600, minLengthOfWindow);

    I use a similar method for decreasing the height of the window when rows are removed.

    basically I do the following whenever a row is added to the table:

    Qt Code:
    1. if ((numberOfRows > 7) && (numberOfRows < 18))
    2. {
    3. minLengthOfWindow = minLengthOfWindow + 30;
    4. Loader::setMinimumSize(600,minLengthOfWindow);
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resizing window depending on QTableView

    Hmm, as my program becomes larger I have come to realize that the above method of resizing the table is quite messy, does anybody have any ideas I could play around with?

    Thanks in Advance

Similar Threads

  1. Resizing a maximized, custom-frame window
    By Claymore in forum Qt Programming
    Replies: 9
    Last Post: 24th November 2010, 18:17
  2. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 16:13
  3. Resizing QTableView
    By ghutchis in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 20:36
  4. Problem on Resizing of QTableView colums ?
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2008, 04:03
  5. [QT4] Any way to disable window resizing ?
    By Amalsek in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2006, 11:36

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.