PDA

View Full Version : Setting fonts on Windows works, but not on Mac



mtnbiker66
17th January 2012, 21:06
I have an application that will be running on both a Mac and on Windows, and due to font size differences I've added the following code to override the default settings that come from developing on both OSs.


//***************************/
//* Windows-only fonts... */
//***************************/
#ifdef Q_OS_WIN
QFont newFont("Lucida Sans", 9, QFont::Normal, false);
QApplication::setFont(newFont);

QFont newFont2("Lucida Sans", 8, QFont::Normal, false);
ui->Calc1LB->setFont(newFont2);
ui->Calc2LB->setFont(newFont2);
#else
//***********************/
//* Mac-only fonts... */
//***********************/
QFont newFont("Lucida Grande", 12, QFont::Normal, false);
QApplication::setFont(newFont);

QFont newFont2("Lucida Grande", 11, QFont::Normal, false);
ui->Calc1LB->setFont(newFont2);
ui->Calc2LB->setFont(newFont2);
#endif


For Windows, this resetting works perfectly for *every* widget but for some reason only works for part of the widgets on my Mac, like line edits and tab headers, but not labels or pushbutton text. I have reset the default fonts just to make sure I hadn't missed any but if that was the case then it wouldn't work on Window.

I can resize the widgets if need be so that my text doesn't get truncated but I'd rather not do that.

Any suggestions? thanks!


-- Kodi