Results 1 to 3 of 3

Thread: QTreeView column resize problem

  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTreeView column resize problem

    Hi,
    i have a problem with resizeColumnToContents of QTreeView:

    I have a QTreeView with 2 columns. The first column should be resized to its contents. The second column shoud use the rest of the space. If some parent in the QTreeView is expanded I call resizeColumnToContents(0).
    It works, but if the parent gets collapsed and expanded once again, the section size of col 0 increases a bit and so on and so on....

    How I can avoid that.


    thanks

  2. #2
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView column resize problem

    I get exasperated with that issue. What could be the problem?

  3. #3
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeView column resize problem

    Did you try to do this:

    Qt Code:
    1. yourView->header()->setResizeMode(0, QHeaderView::ResizeToContents);
    2. yourView->header()->setStretchLastSection(true);
    To copy to clipboard, switch view to plain text mode 

    That should do what you want, without you having to resize the column after each expansion.

Similar Threads

  1. QTableView and column resize problem
    By winkle98 in forum Qt Programming
    Replies: 5
    Last Post: 28th February 2012, 07:51
  2. Replies: 1
    Last Post: 9th May 2011, 00:13
  3. QTreeview last Column visibility
    By kiran p in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2011, 11:25
  4. Replies: 2
    Last Post: 18th October 2010, 18:58
  5. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 08:49

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.