Solved Using QFont
-
Hello!
I'm trying to change the ui's labels' fonts with code. I have a variable which saves the new font size, for example:
int labelSize = 12; ui->label->font().setPointSize(labelSize);
But I have the following error:
'void QFont::setPointSize(int)' : cannot convert 'this' pointer from 'const QFont' to 'QFont &'
and I don't know how to fix it.
Thank you very much!!
-
Hi,
can u try
int fontsize = 50; QFont font; font.setPointSize(fontsize); m_label = new QLabel; m_label->setText("Hello"); m_label->setFont(font);
Thanks,
-
Thank you very much!!
-
-
Hi,
Technically it should rather be:
QFont font = m_label->font(); font.setPointSize(50); m_label->setFont(font);
So you are always sure to modify the font from a given widget which might have bee changed elsewhere.