Results 1 to 3 of 3

Thread: How to change some colors in a QPlainTextEdit

  1. #1
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How to change some colors in a QPlainTextEdit

    Hi:

    I'm creating one of those editors that provide the fonts and colors cutomization functionality. the editor uses as a basis the QPlainTextEdit Class. However I can't find in the documentation how to change the background color of the QPlainTextEdit and the color of the letters. I know these are defined by the OS but isn't there any way to modify them?

    Thanks for any answers.

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to change some colors in a QPlainTextEdit

    Use QPalette:
    Qt Code:
    1. QPalette p = ui->plainTextEdit->palette();
    2. p.setColor(QPalette::Base, Qt::red);
    3. p.setColor(QPalette::Text, Qt::white);
    4. ui->plainTextEdit->setPalette(p);
    To copy to clipboard, switch view to plain text mode 
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to change some colors in a QPlainTextEdit

    Thank you so very much. I'll try that tomorrow.

Similar Threads

  1. Change database data in the QTabelView
    By sophister in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2009, 16:40
  2. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  3. statusBar() message color change
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 23:20
  4. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03
  5. Qt Designer 4.0.1 Preview Colors
    By jtyler in forum Qt Tools
    Replies: 2
    Last Post: 14th February 2006, 15:47

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.