PDA

View Full Version : QTextEdit & background colors



marziac
23rd August 2007, 18:07
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.:confused: 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.:)

darksaga
23rd August 2007, 18:29
how about looking into the qt documentation, or searching the forums first ???

you would have found a solution within minutes...

setting color:


m_textEdit->setTextColor(Qt::red);


setting background


QPalette palette;
palette.setColor(QPalette::Base, QColor(0, 0, 255, 255));
m_textEdit->setPalette(palette);


monospaced text


m_textInput->setFont(QFont("Courier", 10));


regards

marziac
23rd August 2007, 20:00
Thank you, I will try this.

Is possible to do blinking text?.

marziac
24th August 2007, 10:33
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.:confused:

The code for QPalette:

QPalette palette;
palette.setColor(QPalette::Window, QColor(Qt::red));
textOut->setPalette(palette);


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

elcuco
24th August 2007, 12:52
‎Throw HTML to that widget, that can work. (will be slower tough).