Results 1 to 3 of 3

Thread: QTableWidget how to scale the columns and keep the proportions?

  1. #1

    Default QTableWidget how to scale the columns and keep the proportions?

    Hi all! I have a question about QTableWidget. How can I keep a proportion of the columns when I refinable widget table(window application)?
    For example I set for two columns following sizes:

    Qt Code:
    1. self.tableAsset.horizontalHeader().resizeSection (0, 170)
    2. self.tableAsset.horizontalHeader().resizeSection (1, 30)
    To copy to clipboard, switch view to plain text mode 

    Now I get that when you create the window size of the cells are correct, but when you scale extends only the latter, and it is necessary that they are uniformly scaled to keep its current proportions. I want to keep a prescribed proportion. Thanks in advance for your reply. And sorry for my bad English.

  2. #2

    Default Re: QTableWidget how to scale the columns and keep the proportions?

    Please help, who knows how to solve this problem?

  3. #3
    Join Date
    Feb 2010
    Posts
    96
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 5 Times in 5 Posts

    Default Re: QTableWidget how to scale the columns and keep the proportions?

    You have to capture the resize event.

    This was coded in PyQt
    Qt Code:
    1. def resizeEvent(self, event):
    2. # Dynamically resize rows and columns
    3. rowHeight = ( self.size().height() - self.horizontalHeader().size().height())/6 - 1
    4. colWidth = ( self.size().width() )/7 - 1
    5. for x in xrange(0, 6): self.setRowHeight(x, rowHeight)
    6. for x in xrange(0, 7): self.setColumnWidth(x, colWidth)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTableWidget columns size
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 11:33
  2. How to rearrange columns in QTableWidget
    By rittchat in forum Qt Programming
    Replies: 0
    Last Post: 23rd December 2009, 11:17
  3. [QTableWidget] Columns sizes
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 9th March 2009, 07:26
  4. Resizing QTableWidget Columns
    By mbrusati in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2008, 22:26
  5. Maximize columns on QTableWidget
    By marcelrc in forum Newbie
    Replies: 1
    Last Post: 21st May 2006, 15:34

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
  •  
Qt is a trademark of The Qt Company.