Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Setting QApplication::setFont messes up QMessageBox appearance on macOS



  • I have recently ported my Qt app to macOS and the last bump in the road is that the QMessageBox buttons appear very weirdly whenQApplication::setFont is called.

    If I remove the call to QApplication::setFont this is what I see (correct)

    Captura de pantalla 2020-02-08 a las 12.21.13.png

    However if I add it this is what I see:

    Captura de pantalla 2020-02-08 a las 12.21.54.png

    This line is all I'm changing: QApplication::setFont(QFont("Avenir", FONT_SIZE_NORMAL, QFont::Black)); and it functions perfectly on windows just not macOS.

    I'm using Qt version 5.12.0 and am updating to 5.14.1 just in case it's an issue with that. I'm using Qt Creator 4.8 too.

    My QMessageBox code looks like this (no styling of any kind):

    QMessageBox messageBox;
    messageBox.setIcon(QMessageBox::Icon::Information);
    messageBox.setWindowTitle(tr("Updates Found"));
    messageBox.setText("Version 1 is now available to download");
    auto okButton = messageBox.addButton(QMessageBox::Ok);
    auto skipButton = messageBox.addButton(tr("Skip"), QMessageBox::ButtonRole::NoRole);
    auto updateButton = messageBox.addButton(tr("Update"), QMessageBox::ButtonRole::YesRole);
    
    messageBox.exec();
    


  • @mourke
    Is it the changed size or the changed button look that bothers you (not that I know the answer).

    FWIW, I'd just try leaving the application font alone and test using messageBox.setFont() to verify it's not actually an issue about QApplication::setFont(0 per se.


Log in to reply