PDA

View Full Version : QLabel, large, rich text, font size



TheKedge
5th February 2007, 11:07
Hello....
Really simple one ... (sorry for asking really)

How do I get REALLY BIG text into a QLabel?

I'm using,

QString richText ("<h1><b><font color='green'> <font size=24>"+text+"</font></font></b>");
setText(richText);
QWidget::setFixedSize(QLabel::sizeHint());

Apparently, HTML can do <font size=7>, but that's not really big enough - I'd like the thing to be visible from across the room!

I know nothing about HTML:o
thanks
K

sarode
5th February 2007, 11:37
Hello....

Its all magic done by html script. Try this code .. and tell me you can see the text bigger




#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QString>

int main(int argc, char **argv)
{
QApplication a(argc, argv);

QWidget *w = new QWidget(0);
w->setWindowTitle("lokesh");

//QString ritchText("<h1><b><font color='green'> <font size=40>\"+text+\"</font></font></b>");

QString ritchText("<html><head><meta name=\"qrichtext\" content=\"1\" /></head>"
"<body style=\" white-space: pre-wrap; font-family:Sans Serif; "
"font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:200pt;\">Qt Centre</p>"
"</body></html>");


QLabel *label = new QLabel(w);
label->setText(ritchText);

w->setFixedSize(label->sizeHint());

w->show();
return a.exec();
}



You can increase / decrease this
font-size:200pt;

Cheers

TheKedge
5th February 2007, 11:53
Huge text!

wow, that's a lot of html for a bit of black! nice one. thanks

Q: is that a lot for my label to process? or is it done in nanoseconds?


K

jpn
5th February 2007, 11:56
There's no need to use HTML if you don't want to:


QLabel* label = new QLabel("Qt Centre");
QFont font = label->font();
font.setPointSize(72);
label->setFont(font);