Results 1 to 3 of 3

Thread: Resizing QTableView

  1. #1
    Join Date
    Jun 2011
    Location
    Chennai, India
    Posts
    30
    Thanks
    13
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Resizing QTableView

    I'm using a QTableView to show data from a table in the database. The QTableView is inside a QMdiSubWindow. I want to resize the table/subwindow to exactly fit the table content's width and height. Basically i don't want a horizontal scrollbar to appear (There are only 3 columns and the texts are small enough to fit inside the screen).

    Is there any way to make this happen automatically?

    If i use adjustSize() function, the width is a little more than what is required. Is it possible to fit it perfectly?

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Resizing QTableView

    You can try call adjustSize twice. I suspect that during first call scroll bars are taken into account and this may lead to situation when adjusted windows size is little more then required.
    Note that adjustSize is performing asynchronous calculation so second call of adjustSize have to be delayed until this calculations are completed.
    You can test if my suspicion is proper by calling adjustSize when some button is pressed.

  3. #3
    Join Date
    Jun 2011
    Location
    Chennai, India
    Posts
    30
    Thanks
    13
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resizing QTableView

    calling adjustSize() again did not make it proper. I am manually calculating the size of the table and resizing to that size now.

Similar Threads

  1. QTableView resizing to contents.
    By chris_helloworld in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2010, 13:43
  2. Resizing QTableView inside a QTabWidget
    By Aslan in forum Newbie
    Replies: 2
    Last Post: 29th May 2010, 14:50
  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. Resizing QTableView's horizontalHeader
    By Jimmy2775 in forum Qt Programming
    Replies: 4
    Last Post: 20th December 2006, 00:14

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.