A widget to display text
-
Hi! I'm looking for a widget to display rich text (I'm gonna use it in QTableWidget via setCellWidget(..)).
First I thought QLabel was a good solution, but it was not. What is the best alternative to have rich text, background customizing and also frame width, style and color customizing in my text widget? -
"QTextEdit":http://doc.qt.nokia.com/latest/qtextedit.html#details class might be what you are looking for.
-
thank you. Do you know how I can change border color of the QTextEdit?
And if I have about 40-50 QTextEdits in one window, will it cause serious CPU load ?
-
you can easily change colour of text and background using setTextColor() and setTextBackgroundColor(). Changing the border of the text edit itself would - as far as I remember - require using QSS, subclassing, or even own style creation.
-
thank you for reply
setTextBackgroundColor() changes background of the text, when I need changing background of the widget. (color should change depending on whether focus is on widget or not)
what is the best way to do this, who knows? -
bq. First I thought QLabel was a good solution
Could you tell us why it's not a good solution for you? I t can help us understand what you really want.
bq. What is the best alternative to have rich text, background customizing and also frame width, style and color customizing in my text widget?
Are those the only things you want to accomplish?Did you try "stylesheet examples":http://doc.qt.nokia.com/4.7/stylesheet-examples.html?
-
I'm looking through Qt textbook right now, it seems that - as I've mentioned - it is possible through QSS.
Try this:
@
// use your QTextEdit, of course:
QTextEdit test;
test.setStyleSheet("border: rgb(255, 0, 0); ");
@
You can use common colour names, too. For more info, look into documentation:
"Qt Style Sheet":http://developer.qt.nokia.com/doc/qt-4.7/stylesheet.html#id-7e8519ff-eddd-442c-ad11-e4519ccf273a