PDA

View Full Version : Cross-platform Windows & Mac: Font size problem



monkazer
25th July 2012, 00:32
Hello

I'm developing an application on Windows and Mac.
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

wysota
25th July 2012, 08:41
Instead of manipulating the font for each widget (be it for windows or mac), you can just set the default application font. Then you'll just have to perform the changes in one place.

monkazer
25th July 2012, 12:46
Are you talking about the family font or the size font ?
Only the adjusted fonts in windows need to be adjusted on osx too.

wysota
25th July 2012, 15:10
I'm talking about QApplication::setFont().