Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.10.1, 5.11.1
-
None
-
Windows 10
Description
Unless I'm doing something terribly wrong, QFont::setStyleName doesn't work on Windows.
I'm testing it with font styles listed by QFontDatabase, and in my simplified test rendering directly to a QLabel. I've also tried dozens of other font variant/style names, they all effectively render in the parent font family.
#include <QApplication> #include <QDebug> #include <QFontDatabase> #include <QLabel> #include <QMainWindow> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow w; QFont font("Arial", 244.0); font.setStyleName("Bold Italic"); QFontDatabase db; qDebug() << db.styles(font.family()); QLabel* label = new QLabel("Text"); label->setFont(font); w.setCentralWidget(label); w.show(); return a.exec(); }
In the attached screenshot you can see the font rendered is just regular Arial rather than the Bold Italic variant which QFontDatabase tells me should exist.
There are hints in the documentation about the "lack of full cross platform support" for some properties of QFont, but if this is 100% not supported and not likely to be, it would be great to be more explicit (with a note on the method itself for example).