Results 1 to 5 of 5

Thread: QTableWidget Default width of row and column

  1. #1
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QTableWidget Default width of row and column

    Hi,

    I am using QtableWidget and want to set the default width of row and column. So that every time new row is added and there is no need to set the width.

    Thanks & Regards

  2. #2
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget Default width of row and column

    Are you looking for something like this:

    Qt Code:
    1. tableWidget->setColumnWidth( 0, 160 );
    2. tableWidget->setColumnWidth( 1, 100 );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QTableWidget Default width of row and column

    Hi,

    Thanks for reply but i need this

    table->horizontalHeader()->resizeSection(column,10);
    table->verticalHeader()->resizeSection(row,10);

    column and row need to passed only once. I don't want to set again and again

  4. #4
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget Default width of row and column

    Put the code I have posted above into the header (once for each column). No need to do it again and again ...

    But may be this is what you are really looking for:

    Qt Code:
    1. tableWidget->verticalHeader()->setDefaultSectionSize(50);
    2. tableWidget->horizontalHeader()->setDefaultSectionSize(200);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QTableWidget Default width of row and column

    Hi,

    Thanks It works as I want

Similar Threads

  1. Handle QTableWidget's column width change
    By dorians58 in forum Newbie
    Replies: 0
    Last Post: 28th July 2010, 20:24
  2. Replies: 0
    Last Post: 16th March 2010, 04:54
  3. QTableWidget column width and resizing
    By shooogun in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2008, 23:31
  4. changing column width of QTableWidget
    By juliarg in forum Newbie
    Replies: 4
    Last Post: 22nd March 2007, 16:51
  5. Replies: 6
    Last Post: 13th October 2006, 15:40

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.