[Interest] Macro to identify desktop(Ubuntu-X86) and embedded Linux(ARM)

Allan Sandfeld Jensen kde at carewolf.com
Sun Sep 9 00:04:53 CEST 2018


On Samstag, 8. September 2018 22:56:29 CEST Thiago Macieira wrote:
> On Saturday, 8 September 2018 11:56:45 PDT Tomasz Olszak wrote:
> > So as well you can to it in runtime and don't need macro.
> 
> Better yet, don't do anything. Use the font that the user configured and
> don't override. If you don't like the font, use your desktop's font
> changing tool to make the customisation.

And getting the system default fonts can be a bit tricky, but it is done like 
this:

QFontDatabase db; // needs to be instantiated at least once first
QFont defaultFont;
defaultFont.setStyleHint(QFont::SansSerif);
defaultFont = QFont(defaultFont.defaultFamily()));

You have to use QFont first as a query to query the default, and then you can 
set the default name to get the actual default font. This is because 
QFont::StyleHint generally isn't working well cross-platform, and it is also 
not quite clear what it is supposed to do in general font queries, but it can 
query default font families like this.

I might have cleaned parts of this up so it is less error-prone, but this
is at least the old standard incantation for font defaults.

'Allan







More information about the Interest mailing list