Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QFontDialog and styleHint() stopped working



  • Hi,

    I do a simple QFontDialog and then to find out if the user selected a Serif, Sans Serif, Cursive, or Typewrite font, I call styleHint() on the returned font.

    This used to work perfectly, but it seems it's broken in 5.15.2.

        switch(font.styleHint())
        {
            case QFont::SansSerif :
                // do stuff
                break ;
    
            case QFont::Serif :
                // do stuff
                break ;
    
            case QFont::Cursive :
                // do stuff
                break ;
    
            case QFont::TypeWriter :
                // do stuff
                break ;
    
            default :
                // do stuff
                break ;
        }
    

    Always hits the default. This is a change from 5.14, which was the last version of Qt I used.

    Is this a known issue?

    Gerald



  • Hmmm, the issue may be mine. I recently switched from wxWidgets to Qt, and the styleHint() may not have worked from day one.

    Is there a way to find out if a font is serif or sans serif or ....?

    I can find out if a font is fix pitched or not using QFontInfo, but that seems to be it.

    Gerald


Log in to reply