Results 1 to 5 of 5

Thread: QTableWidget column and row sizes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget column and row sizes

    Hello,

    Currently I have the following question. How could I set:

    - Default row height of a QTableWidget row
    - Default column width of a QTableWidget column

    I know you can do this by implementing sizeHint in a QItemDelegate, and use resize functions, but since I have douzens of rows and columns I want a decent default size.

    On the 'old' Qt forum there was a post by someone who provided a 'patch', for the row height (defaultSectionSize method and sectionSizeFromContents), but that patch doesn't work for some reason. I cannot post on that forum anymore, so I would appreciate it if some Qt guru could tell me how to implement this.

    Greets,
    Arthur

  2. #2
    Join Date
    Jan 2006
    Posts
    24
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget column and row sizes

    Hi,

    use QHeaderView::resizeSection

  3. #3
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget column and row sizes

    Thank you for your reply.

    The problem is that I absolutely don't want to resize, since this is way to slow. I want to change the default size.

    Arthur

  4. #4
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget column and row sizes

    resizeSection is a better way to resize hight of all your rows...
    it works fast, if you use setUpdatesEnabled...

    the default row height you can't set at all.

    here is an example... it's wrote on Qt3, but i think it will work on Qt4 similar...

    Qt Code:
    1. verticalHeader()->setUpdatesEnabled(FALSE);
    2.  
    3. for (unsigned int i = 0; i < numRows(); i++)
    4. verticalHeader()->resizeSection(i, rowHeight);
    5.  
    6. verticalHeader()->setUpdatesEnabled(TRUE);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget column and row sizes

    Ok thanks, that helps a lot...

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.