Christophe
Christophe

Reputation: 953

Qt Cross-platform Windows & Mac: Font size

I'm developing an application on Windows and OS X, with Qt framework.
The problem is that I have manually set up the font size for some widgets (in the ui designer).
Under windows, the fonts are perfect, but on osx, they are too big.
Indeed, the font families are converted (MS Shell Dlg 2 to Lucida Grande), but not the font size, if they have been manually set.

So I decided to decrease the font size in the code, with some #ifdef, like this for example:

#ifdef Q_OS_MAC
QFont font = ui->button->font();
font.setPixelSize(12);
ui->button->setFont(font);
#endif

It's working but it's a bite annoying when you have a lot of widgets, so I'm open for any other ideas.

I have also a qtextedit which has this problem, and this solution doesn't works, cause it's the html code which need to be adjusted.

Thanks

Upvotes: 3

Views: 3877

Answers (1)

Stephen Chu
Stephen Chu

Reputation: 12832

You may try style sheet set globally in the application, or one widget (and its subs) at a time. Something like:

#ifdef Q_OS_MAC
window->setStyleSheet("QWidget{font-size:12px}");
#endif

Upvotes: 1

Related Questions