Results 1 to 3 of 3

Thread: QTreeWidget Items display too wide.

  1. #1
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default QTreeWidget Items display too wide.

    Hi,
    Please can someone help with a problem I'm having with the QTreeWidget. The tree has only 1 column and I've set my tree up with the following so that I get appropriate scrollbars and item labels aren't truncated.

    mytree->header()->setResizeMode(0, QHeaderView::ResizeToContents);
    mytree->header()->setStretchLastSection(false);

    The problem I have is that items in the tree seem to be sized to fit the entire width of the column. When you select and item in the tree the blue highlight is therefore stretched beyond the actual text of the item. For example, an item is selected and the highlight covers just the text. Then you sunsequently expand an item, (which results in the column being resized wider), the highlight of the selected item changes.

    I want the item text only to be highlighted, (as per apps like windows explorer), and not the full width of the tree.

    Any help would be appreciated.

  2. #2
    Join Date
    Feb 2010
    Location
    Hyderabad, India
    Posts
    15
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidget Items display too wide.

    In order to select just the items and not the complete row, then try to do the following.

    mytree->setSelectionBehaviour(QAbstractItemView::SelectIt ems);

  3. The following user says thank you to mrvk for this useful post:

    chris_helloworld (26th February 2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: QTreeWidget Items display too wide.

    Brilliant thanks, just what I wanted.

Similar Threads

  1. removing items QTreeWidget
    By Mystical Groovy in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2015, 21:58
  2. Getting system wide X11 events problems
    By wandereq in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2010, 20:13
  3. The order of items in QTreeWidget
    By KK in forum Qt Programming
    Replies: 4
    Last Post: 27th February 2009, 04:54
  4. amount of items in QTreeWidget
    By supergillis in forum Qt Programming
    Replies: 4
    Last Post: 1st August 2008, 22:38
  5. QTreeWidget - locating items in viewport
    By kemp in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2007, 15:18

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.