Results 1 to 1 of 1

Thread: QTreeWidget after calling setFont(), the column width suits no more to its content

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Location
    Karlsruhe, Germany
    Posts
    57
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QTreeWidget after calling setFont(), the column width suits no more to its content

    Hello all,

    imagine there is a qtreewidget i used with 3 columns.
    by default without setting the font using QTreeWidget::setFont() the content displayed after calling show()
    suits to the contents.

    While if i call the setFont() the first column always occupies the whole row, i need to scroll the horizontal bar to see
    the rest of contents in 2nd and 3rd column.

    is it a known bug?

    PS: i think the way to setup the strech flag - QHeaderView::setResizeMode ( ResizeToContents) is not the way it is supposed to cause it limits the flexibility
    in which the the user cannot adjust the column width by mouse.

    After deeper debug, i found that when calling setFont() before settingup the header leads to a column size update...

    Qt Code:
    1. case QEvent::FontChange:
    2. case QEvent::StyleChange:
    3. d->invalidateCachedSizeHint();
    4. resizeSections();
    5. emit geometriesChanged();
    6. break;
    To copy to clipboard, switch view to plain text mode 

    while the header contains only one default column, the size is then set to the width of the whole row.
    Last edited by cic; 12th May 2014 at 13:24.

Similar Threads

  1. calling setFont() twice causes infinite repaint
    By Cruz in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2012, 21:22
  2. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 09:58
  3. QTreeWidget Crashing while setText,setFont,setIcon
    By santosh.kumar in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2008, 11:36
  4. set Column Width in QTreeWidget?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:12
  5. Change column width in a QTreeWidget
    By mace in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2006, 12:19

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.