qtqt5qcomboboxqt6qfont

How can I fill a QComboBox with all fonts from QFontDatabase?


I want to add all fonts from my pc to QComboBox, how can I do it?

I expect a combobox list which will include all fonts from my PC. As I think, it can be possible with QFontDatabase.


Solution

  • As said in comments to your question, QFontComboBox should be helpful.

    But for some reason if you are not interested in that, you can do it in traditional way.

    Get the font families as a string list using QFontDatabase::families(), and then fill the combobox:

    comboBox->addItems(QFontDatabase::families());