Results 1 to 3 of 3

Thread: Forcing equal row heights in QTableWidget

  1. #1
    Join Date
    Oct 2009
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Forcing equal row heights in QTableWidget

    I'd like the height of all rows in a QTableWidget to change when any row is resized. I can use verticalHeader()->setDefaultSectionSize() to set the row height, but how do I detect when I need to do this? There's a resizeEvent that I use to adjust column widths when the whole table is resized, but there doesn't seem to be an event triggered by resizing rows. Am I missing something obvious?

    I'm using the 4.6.0 beta under Windows with MinGW.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Forcing equal row heights in QTableWidget

    Hi,

    fetch the QHeaderView::sectionResized() signal and then set the corresponding hight for all rows.

  3. #3
    Join Date
    Oct 2009
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Forcing equal row heights in QTableWidget

    Thanks, I'm much closer to getting it to work now. The first complication is that whether I set the height for each row or do them all at once with setDefaultSectionSize, a sectionResized signal is sent for each row. I don't get an infinite loop, so I guess setting the height to the value it already has doesn't generate a signal.

    I can avoid the extra signals by blocking them or by disconnecting. If I block signals from the verticalHeader, display of both the header and the table tend to get messed up, and update or repaint from within the signal handler doesn't help. (Manual scrolling fixes it.) If I disconnect from the signal, only the vertical header display is messed up.

    If the row I'm resizing is the first one in the table, things look good. But if it's a later row, or worse if the table has been scrolled, the row being resized moves, perhaps out of the viewport.

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.