Results 1 to 4 of 4

Thread: Changing the text color of a QTreeView leaf.

  1. #1
    Join Date
    Feb 2006
    Posts
    47
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Changing the text color of a QTreeView leaf.

    Hello, my QTreeView needs to have its tree leaves' colors changed based on some flag settings. How do I do this? I wish to iterate through the entire tree (already set up from a model), check the flags, and change the childless items red where the flag setting is true.

    I guess I simply do not know how to access the QTreeWidgetItem so that I may change its properties. Is this possible? Am I stuck with the default colors with QTreeView?

    John.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing the text color of a QTreeView leaf.

    Set colours in the model by using setData() and Qt::BackgroundColorRole or Qt::TextColorRole depending on which colour you want to change.

  3. #3
    Join Date
    Feb 2006
    Posts
    47
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing the text color of a QTreeView leaf.

    But how do I get the required QModelIndex?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Changing the text color of a QTreeView leaf.


Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10: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.