How to change font size at the application?
-
I need change font size at the application, for example: at the settings user can choose: small, medium or large font size, how to dinamical change a font size at the all of application windows?
-
Hi
Using QFontDialog
"Font Dialog":http://qt-project.org/doc/qt-5/qfontdialog.html -
Hi
in addition to answer of 2nd Question
"QApplication":http://qt-project.org/doc/qt-5/qapplication.html#setFonthope it helps.
-
Tnx 4 answers!
About QApplication::setFont - i know that method, but when i set the font using it - nothing happend :( font still the same as was. -
The behavior of fonts vary from OS to OS.
Did you pass second parameter as class in QApplication::setFont.? -
nope, only put font object to the method.
i test at the linux, mac and android - nothing changed.
about second arg - i need change font size at the all of ui object. -
Hi
Please pass second argument as well.
For eample if you want to change font of all QWidget then pass "QWidget" -
emmm..... ok maybe some one know base container name for qml elements? :)
-
Hi,
[quote author="Maxim Prishchepa" date="1412776706"]nope, only put font object to the method.
i test at the linux, mac and android - nothing changed.
about second arg - i need change font size at the all of ui object.[/quote]Which Qt version are you using ? The below code works for me:
@
QGuiApplication app(argc, argv);
QFont f = app.font();
f.setFamily("Monaco");
f.setPointSize(32);
app.setFont(f);
QQuickView view;
...
@ -
Hi p3c0!
Tnx 4 answer!
I use Qt 5.3.2.About your code: i should give to user posibility to chenge font on runtime, when QQuickView object is already created.
As options: check recurcive all child object at the QQuickView container, but it's take a time :( maybe some other options? -
Well then Binding is your friend here. Create a global variable for eg:
@
property real appfontSize: 12.0
@Then bind this property to all other components font.pointSize wherever applicable and when the user chooses a font size, change appfontSize to new size and thus will change binded components font size.
-
p3c0 - tnx 4 answer, i'll try it.