Results 1 to 5 of 5

Thread: QTextEdit & background colors

  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Question QTextEdit & background colors

    Hi,

    I am trying to code a telnet client, like putty or linux terminal. I'm using QTextEdit to show text in screen but it have some problems. I need to show text in fixed sized font, differents colors, different background colors(text background color, not Widget background) and flashing text. It seems to be easy with html but it doesn't work properly. Then I used QTextCursor but I have the same problems. Ok, is it possible this project with QTextEdit? or the only way is to draw it directly?. If i have to draw directly, can I copy&paste from this text?.

    Thanx and sorry for my English.

  2. #2
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTextEdit & background colors

    how about looking into the qt documentation, or searching the forums first ???

    you would have found a solution within minutes...

    setting color:
    Qt Code:
    1. m_textEdit->setTextColor(Qt::red);
    To copy to clipboard, switch view to plain text mode 

    setting background
    Qt Code:
    1. QPalette palette;
    2. palette.setColor(QPalette::Base, QColor(0, 0, 255, 255));
    3. m_textEdit->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

    monospaced text
    Qt Code:
    1. m_textInput->setFont(QFont("Courier", 10));
    To copy to clipboard, switch view to plain text mode 

    regards

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

    marziac (23rd August 2007)

  4. #3
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Default Re: QTextEdit & background colors

    Thank you, I will try this.

    Is possible to do blinking text?.

  5. #4
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Default Re: QTextEdit & background colors

    Hello,

    I try the QPalette code and it don't works. I was using setStyleSheet to set background of the Widget to black but it makes changing fonts imposible.

    The code for QPalette:
    Qt Code:
    1. QPalette palette;
    2. palette.setColor(QPalette::Window, QColor(Qt::red));
    3. textOut->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

    I changed "QPalette::Window" with "QPalette::Text" and others but it don't change text background color. I will try to explain what I need other time. I want to highlight some parts of text with different background colors. It's easy to change all widget background but I need only parts of text, the other text background must remain black.
    Is not possible with QTextEdit?.

    Thanx all

  6. #5
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit & background colors

    ‎Throw HTML to that widget, that can work. (will be slower tough).

Similar Threads

  1. Qt4 - QTextEdit - background color
    By impeteperry in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2009, 08:52
  2. QTextEdit with semi-transparent background
    By ber_44 in forum Qt Programming
    Replies: 6
    Last Post: 29th April 2007, 01:01
  3. Replies: 1
    Last Post: 5th April 2006, 17:44
  4. Qt Designer 4.0.1 Preview Colors
    By jtyler in forum Qt Tools
    Replies: 2
    Last Post: 14th February 2006, 16:47
  5. Rich Text Tale Vol1 : Background colors
    By fullmetalcoder in forum Qt Programming
    Replies: 37
    Last Post: 9th February 2006, 16:05

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.