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
-
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
fontproperty?BTW
In doc QApplication::setFont()On application start-up, the default font depends on the window system.
But in a
.uifile, 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.
-
e.g.
For Linux,notomight be a good default choice, for Windows,Tahomamight be.
As in a.uifile, a widget and its children could have different fonts.
Is it necessary to change the font of every widget that has propertyfont?@jronald 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. -
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.
-
@jronald 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.@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.
-
@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.
@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()?
-
@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? -
@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....
-
@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/
-
@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?:
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.
-
@JonB The bug removed something, did not set a font: https://forum.qt.io/topic/134040/
@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 :)