Results 1 to 6 of 6

Thread: Changing selected QTreeView item font

  1. #1
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Changing selected QTreeView item font

    How can I change the font of selected QTreeView item to bold? Is it possible with stylesheet?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing selected QTreeView item font

    This style sheet should work :
    QTreeView::item:selected {
    bfont: bold;
    }

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

    dima1000 (11th October 2009)

  4. #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: Changing selected QTreeView item font

    you can get current item using QAbstractItemView::currentIndex and then using Qt::FontRole set a font.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    dima1000 (11th October 2009)

  6. #4
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Re: Changing selected QTreeView item font

    yogeshgokul , it's not working. It's possible to change a colors this way, but not a font

    spirit, thank you, it's working

  7. #5
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing selected QTreeView item font

    Quote Originally Posted by dima1000 View Post
    yogeshgokul , it's not working. It's possible to change a colors this way, but not a font
    There is a typo in style sheet I pasted. Notice that extra "b" before "font". Anyways no probs when your problem is solved.

  8. #6
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Windows

    Default Re: Changing selected QTreeView item font

    I did it with "font", and no with "bfont"
    Anyway I preffer to do this with stylesheet, because if not, I need to catch selection changes, and to save previous selections to change them back. But I can't find the way to do this with stylesheet.

Similar Threads

  1. How to get parent of selected item in TreeView?
    By RavenS in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2009, 13:27
  2. QTreeView, QSortFilterProxyModel and item expansions
    By benacler in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2008, 20:30
  3. Changing font color for a single item in a QTreeView
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2007, 19:14
  4. Changing selected item color in non-current window.
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2007, 07:09
  5. QTreeView: selection behavior upon selected item removal
    By Pieter from Belgium in forum Qt Programming
    Replies: 6
    Last Post: 11th July 2007, 16:00

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.