Multiple Font Sizes with on the fly sizing
-
Hi,
I'm looking for ideas.
Our application uses three different font sizes (small, medium, large). I want to be able to change any of them on the fly and have the application update correctly. That is, if I change the medium font from size 10 to 12, I want all current widgets of size 10 to change to size 12 and of course, new widgets would come in at size 12.
Currently, I have my own setFont and track the widgets there. Then when the font size is changed I can just set the font on the widget list to the new size and the display updates. This is slow and I'm having some troubles with QTreeWidgetItems (and sip).
First a little background. This application runs standalone, but mostly we run it within Maya (which is now a QT app too). So I can't use QApplication.setFont because that would change Maya's fonts too. So it seems I do need a font manager of some kind.
My biggest problem is the calls to QLabel and others that don't explicitly setFont. I have to find all those calls and do a setFont there.
Does anyone have any easier suggestions as how to do global font changes and have them be live right away?
Thanks,
Howard -
In MainWindow you could use the following line:
@ this->setStyleSheet(QString::fromUtf8("font: 10pt FreeMono;"));@to set FreeMono 12pt font globally...
You can also limit the stylesheet to some widgets by properly defining the stylesheet, e.g:
@ this->setStyleSheet(QString::fromUtf8("QLabel {font: 10pt;}"));@
just to set font size only for QLabels...I hope it helps.