Results 1 to 3 of 3

Thread: Highlight a part of QTreeWidgetItem name

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Highlight a part of QTreeWidgetItem name

    Hi all,
    I have a widget who is a QTreeWidget with a search box.
    I only show items who contains the text in the search box.
    I would highlight the part of the QTreeWidgetItem name who is the search box value.
    I would a simple background color on the part of the name found.
    Is it possible with Qt ? How can I got it working ?
    Thanks for the help

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Highlight a part of QTreeWidgetItem name

    Is it possible with Qt ?
    Yes it is possible in Qt.

    How can I got it working ?
    It is not trival to do this QTreeWidget and QTreeWidgetItem. You can set costom widgets in place of the QTreeWidgetItems, and connect the search widget to the custom widgets. Text highlighting (partial/full) should be done in the custom widgets. These custom widgets could be QLabels, and can use html tags to hightlight the matched text.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Highlight a part of QTreeWidgetItem name

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Replies: 11
    Last Post: 3rd March 2012, 22:21
  2. Replies: 2
    Last Post: 23rd August 2011, 12:23
  3. Replies: 5
    Last Post: 23rd September 2010, 13:58
  4. highlight in QTextEdit
    By ubuntudevelop78 in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2009, 00:22
  5. Q3ListView highlight part of a column
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2006, 09:26

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.