Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Show only application fonts in QFontComboBox?



  • At the start of my application, I call
    @QFontDatabase::removeAllApplicationFonts();@
    and then add some fonts that I want to use.

    Is there any way to restrict QFontComboBox to only those fonts?


  • Moderators

    since it's a ordinary QComboBox you can set your own model to it.
    QFontComboBox uses a simple QStringListModel, containign the font names as strings.
    Take a look at the Qt source of QFontComboBoxPrivate::_q_updateModel() for further info.



  • Thanks!

    (message too short)



  • Didn't work. The model is automatically reset to the whole font database in too many places. Since setModel is not virtual, there's also no clean way to override this behavior.

    Seems the only way to do this is to write your own widget.


Log in to reply