Results 1 to 4 of 4

Thread: Resizing columns of a table?

  1. #1
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Resizing columns of a table?

    Hi all,

    I am using QTableView for generating a table for my data. Problem is that i want the table to capture all the horizental space available in the TableView but i can't make it yet.

    I used following LOC but invain...
    Qt Code:
    1. tableView_processInfo->horizontalHeader() -> resizeSections(QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 

    For just testing i wrote:
    Qt Code:
    1. tableView_processInfo->setColumnWidth(2,500)
    To copy to clipboard, switch view to plain text mode 
    but it did not result into anything either.

    where tableView_processInfo is my table's name. Also, have a look of the attached picture to see what's wrong.

    Thanks a lot
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Resizing columns of a table?

    Problem Solved!

    Following LOC did what i wanted
    Qt Code:
    1. tableView_processInfo->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 

    One more problem

    I wanted that the columns may take the available space as well as the user may be able to change the width of the columns 'interactively' so i used following LOCs. The interactively changing widths worked but the first problem is still there i.e. columns are not taking the available space even though i have stretched the last section...Any idea?

    Qt Code:
    1. tableView_filesInfo->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    2. tableView_filesInfo->horizontalHeader()->stretchLastSection();
    To copy to clipboard, switch view to plain text mode 

    Thanks again..

  3. #3
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Resizing columns of a table?

    stretchLastSection() is a getter to the property stretchLastSection, it is not a slot that does anything. Try setStretchLastSection(true)
    It's nice to be important but it's more important to be nice.

  4. The following user says thank you to axeljaeger for this useful post:

    qtzcute (16th August 2009)

  5. #4
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Resizing columns of a table?

    oh i missed that. Thanks

Similar Threads

  1. Resizing QTableWidget Columns
    By mbrusati in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2008, 22:26
  2. Replies: 1
    Last Post: 24th July 2008, 18:20
  3. Table with number of columns depending on row?
    By Arghargh in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2008, 13:03
  4. QTreeWidget, proper resizing of columns
    By soul_rebel in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2007, 01:06
  5. How to capture resizing of QTreeWidget columns?
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2006, 06:10

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.