Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFontDatabase::styles(const QString & family) Returning Non Existent Style Data.
Forum Updated to NodeBB v4.3 + New Features

QFontDatabase::styles(const QString & family) Returning Non Existent Style Data.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bfWrangler
    wrote on 30 Nov 2011, 16:20 last edited by
    #1

    Hello,

    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
    QFontDatabase fdb;
    QComboBox * combo = this->ui->styleCombo;

    combo->setEnabled(true);
    combo->clear();
    combo->addItems(fdb.styles(font.family())); //add the list of styles
    //select the first item
    if(combo->count() > 0)
    combo->setCurrentIndex(0);
    else
    combo->setEnabled(false);

    }
    @

    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?

    1 Reply Last reply
    0

    1/1

    30 Nov 2011, 16:20

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved