2
votes

With a QFontDialog I get a QFont object as return value. I am using Qt stylesheets with widgets, so setting myWidget->setFont(fontFromDialog) does not seem to have any effect.

Can I translate a font object into a qss string representing the values of the font, similar to font.toString() used with the settings.

2

2 Answers

2
votes

You can set the font straight from the dialog using getFont, i'd try this potentially, might have to alter some code.

myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));

Also, have a look at the Qt documentation for this as it could potentially help a lot!

1
votes

Try this:

QFont aFont;
QString theStyleSheet = QString("font: 75 %1pt \"%2\"").arg(aFont.pointSize()).arg(aFont.family());