Results 1 to 4 of 4

Thread: Change Font Color of Label and CheckBox

  1. #1
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Change Font Color of Label and CheckBox

    How to change the font color in a CheckBox and Label:

    Thanks in advance

    Mahe2310

  2. #2
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Font Color of Label and CheckBox

    try something like this for label
    Qt Code:
    1. QLabel* lbl = new QLabel("<h1><font color=\"red\">SOME TEXT</font></h1>");
    2. lbl->setTextFormat(Qt::RichText);
    To copy to clipboard, switch view to plain text mode 
    or try to use QObject::setFont(const QFont&)
    Last edited by wysota; 15th June 2006 at 11:38.

  3. #3
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Font Color of Label and CheckBox

    Another solution:
    Qt Code:
    1. plt.setColor(QPalette::WindowText, Qt::red);
    2. QCheckBox* cb = new QCheckBox("bla bla bla");
    3. cb->setPalette(plt);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 15th June 2006 at 11:38. Reason: Added [code] tags

  4. #4
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Change Font Color of Label and CheckBox

    Quote Originally Posted by gkuznets
    Another solution:
    QPalette plt;
    plt.setColor(QPalette::WindowText, Qt::red);
    QCheckBox* cb = new QCheckBox("bla bla bla");
    cb->setPalette(plt);
    I am getting a color box instead of the checkbox with the color specified...

    I attached the image which is generated by the command...

    The third checkbox is the result of the above comannds...
    The first two are the results of the normal checkbox... But as not
    able to change the font color it is not showing the text...
    Attached Images Attached Images

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.