PDA

View Full Version : How to change font size in QLabel(QLabel created from Qdesigner)



arunvv
1st August 2008, 22:44
Hi All,

How to change font size for a QLabel? Qlabel was created fron QDesigner.
Before querying to you all I tried changing code as explained in previous posts.
http://www.qtcentre.org/forum/f-qt-programming-2/t-qlabel-large-rich-text-font-size-5508.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-changing-qlabel-font-sizelabel-created-on-the-graphicsview-8597.html

snippet of code:
Method 1:


label1->setText("Qt Label1");
//set font
QFont font = label1->font();
font.setPointSize(72);
font.setBold(true);
label1->setFont(font);

Method 2:


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:70pt;\">
Qt Label1 </p>" "</body></html>");
label1->setText(ritchText);

Even after the changes applied from above posts, it not increasing the font size for a QLabel.

The only difference I can see is my QLabel was created from QDesigner and in the posts it was created manually. Is this(creating qlabel from designer) causing me difficulty in changing the font size for a qlabel? Please help.

Thanks & Regards,
Arun.

GTBuilder
2nd August 2008, 15:46
Arun,

I've used the following code with a QDesigner created QLabel with no problems:



QFont f( "Arial", 10, QFont::Bold);
textLabel->setFont( f);


Regards,

Don