How to set different fonts according to different OSes?
-
Set the globally used font to the one you want via QApplication::setFont() in your main.cpp
-
@Christian-Ehrlicher said in How to set different fonts according to different OSes?:
Set the globally used font to the one you want via QApplication::setFont() in your main.cpp
Will it set the font of every widget that has
font
property?BTW
In doc QApplication::setFont()On application start-up, the default font depends on the window system.
But in a
.ui
file, there is always a specific font, so how can there be a default font which depends on the window system? -
If you don't see a specific font in the ui file then the font from the parent (and in the last resort this is QApplication) will be used. So don't set a font in the ui file and use QApplication::setFont() if you want a custom font instead the one provided by the OS.
-
@Christian-Ehrlicher said in How to set different fonts according to different OSes?:
If you don't see a specific font in the ui file then the font from the parent (and in the last resort this is QApplication) will be used. So don't set a font in the ui file and use QApplication::setFont() if you want a custom font instead the one provided by the OS.
Thank you, but with a newly created application, the font is already there, and no way to remove it.
-
@stretchthebits said in How to set different fonts according to different OSes?:
Isn't that something that you should let your users choose?
Have a font dialog box open and let the user choose what he wants.Yes, but good default settings are better, a lot of users are used to default values.
-
@jronald said in How to set different fonts according to different OSes?:
the font is already there, and no way to remove it.
I don't understand what you want to tell us - what's the problem setting a new font with QApplication::setFont()?
-
@Christian-Ehrlicher said in How to set different fonts according to different OSes?:
If you don't see a specific font in the ui file then the font from the parent (and in the last resort this is QApplication) will be used. So don't set a font in the ui file and use QApplication::setFont() if you want a custom font instead the one provided by the OS.
@Christian-Ehrlicher said in How to set different fonts according to different OSes?:
I don't understand what you want to tell us - what's the problem setting a new font with QApplication::setFont()?
I mean I'd like that there is no specific font in the ui file, but there is always one.
QApplication::setFont()
should work, it'll be better if there is no specific font in the ui file, any way? -
@jronald said in How to set different fonts according to different OSes?:
it'll be better if there is no specific font in the ui file
I have a feeling that quite a while ago there was a thread in this forum discussing this issue. I may (well) be mistaken, but I thought it was decided it was a "bug" that Designer put any explicit font in for you if you did not choose one yourself. Is that your case? I thought that might have altered in some later version of Qt/Designer, but you would have to track down the thread....
-
@JonB The bug removed something, did not set a font: https://forum.qt.io/topic/134040/
-
@jronald said in How to set different fonts according to different OSes?:
I mean I'd like that there is no specific font in the ui file, but there is always one.
No, there is not as long as you don't explicitly set one. It just shows you the current defaults as in every other setting you're seeing there and is not bold.
-
@Christian-Ehrlicher said in How to set different fonts according to different OSes?:
@JonB The bug removed something, did not set a font: https://forum.qt.io/topic/134040/
Prefect, that was the one! Seems that was indeed the other way round from this post :)