Results 1 to 3 of 3

Thread: setforeground of a QTextCharFormat

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Location
    Chandigarh, India
    Posts
    62
    Thanks
    8
    Thanked 11 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default setforeground of a QTextCharFormat

    I am setting the foreground of a QTextCharFormat named as qf.setforeground(Qt::yellow);... There are number of color options but there is no color option for Orange. Can anyone suggest me how to set this to orange color?

  2. The following user says thank you to aaditya190 for this useful post:


  3. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: setforeground of a QTextCharFormat

    You can use QColor constructor that takes rgb values:
    Qt Code:
    1. qf.setforeground(QColor(255, 165, 0));
    To copy to clipboard, switch view to plain text mode 
    or use one of the color names listed here : SVG color keywords
    Qt Code:
    1. qf.setforeground(QColor("orange"));
    To copy to clipboard, switch view to plain text mode 

  4. #3
    Join Date
    Nov 2013
    Location
    Chandigarh, India
    Posts
    62
    Thanks
    8
    Thanked 11 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: setforeground of a QTextCharFormat

    It worked.. Thank You very much...

Similar Threads

  1. QTextCharFormat question
    By moez in forum KDE Forum
    Replies: 1
    Last Post: 1st February 2012, 09:14
  2. QTextCharFormat and Hyperlinks
    By Rayven in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2010, 21:12
  3. QTextCharFormat::setAnchor
    By ccf_h in forum Qt Programming
    Replies: 0
    Last Post: 30th November 2008, 17:01
  4. QTextCharFormat::setAnchorNames
    By ccf_h in forum Qt Programming
    Replies: 0
    Last Post: 30th November 2008, 13:58
  5. QTextCharFormat and QVariant
    By fullmetalcoder in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2007, 11:55

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.