Important: Please read the Qt Code of Conduct -

can I change default fontsize?

  • Hi,

    I'm using Qt6.2 (binary edition) on debian 11.

    The window with the black titlebar is my app created with Qt. Afaik kde is built with Qt too, so I expect the default styles follow KDE-styles in use.

    But thats not the case:

    Red boxes 1 and 2 show default font of kde windows.
    Green boxes 3 and 4 show default gnome fonts on kde. Ok, I admit, that gnome is not well supported in kde systems ...
    But imho Qt should follow kde rules ...

    Even more strange is blue box 5 - that's an editor build following the sample qt code from editor with line numbers. I changed the font of QPlainTextEdit (the source view). That changed font is not respected by the QPainter build on every call of paintLineNumbers.

    I had to add a line like:


    to get the line numbers of same size as displayed code.

    I had to increase the font sizes by 4 points to get same visual impression than compiled with Qt5.15 ...

    Is there a way to change default fontsize once (at application startup or so)?

  • Lifetime Qt Champion

    you can set on Application

    QApplication a(argc, argv);

    But you cant have stylesheets that set fonts also as then it wont override.

  • Hi,

    thank you very much for the hint! Works great!

    The elements where I manually change font continue to work as before.
    ... and the elements, I don't want to use bother with font size use the new application font. Great!

    Thanks again - that's exactly what I was looking for :)

Log in to reply