Results 1 to 3 of 3

Thread: set color in QTreeWidgetItem text

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default set color in QTreeWidgetItem text

    Hello, i have a QTreeWidgetItem * item and i'd like to set the color font in red and the font style in bold.
    I made in this way
    Qt Code:
    1. QFont font("" , 9 , QFont::Bold );
    2. item->setFont( 0, font );
    To copy to clipboard, switch view to plain text mode 
    but i dont know how to set the font in red color, QTreeWidgetItem does not have palette() and setPalette() methods and i dont know another way to do it.
    any hint?
    thx

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: set color in QTreeWidgetItem text


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

    mattia (7th January 2008)

  4. #3
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: set color in QTreeWidgetItem text

    thx i did it in this way
    Qt Code:
    1. QFont font("" , 9 , QFont::Bold );
    2. QBrush b (Qt::red);
    3. item->setForeground( 0 , b );
    4. item->setFont( 0, font );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. formatted text in QTreeWidgetItem
    By swiety in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2007, 16:26
  4. QTreeWidgetItem setting color for the text
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 29th August 2007, 17:22
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

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.