QFontDatabase::styles(const QString & family) Returning Non Existent Style Data.
bfWrangler last edited by
I'm working on a form which has two combo boxes, one QFontComboBox and a second combo box which I populate with the styles after a font is chosen. The code I have to set the styles box after a font is selected is:
void AddNewFont::fontChanged(const QFont& font)
//get the available styles from the QFontDatabase and load into the styles combo
QComboBox * combo = this->ui->styleCombo;
combo->addItems(fdb.styles(font.family())); //add the list of styles
//select the first item
if(combo->count() > 0)
This code works in populating the styles combo box, but for some fonts it is returning too many styles. For example I have the font "Garamond Premr Pro Smbd" whose only style is "Semibold", yet fdb.styles(font.family()) returns, "demibold" "demibold italic" "bold" and "italic". This problem has occurred with multiple other fonts as well. Has anyone else had a similar issue or know what I'm doing wrong that these incorrect styles are being returned?