Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting QApplication::setFont messes up QMessageBox appearance on macOS
Forum Updated to NodeBB v4.3 + New Features

Setting QApplication::setFont messes up QMessageBox appearance on macOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 323 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mourke
    wrote on last edited by mourke
    #1

    I have recently ported my Qt app to macOS and the last bump in the road is that the QMessageBox buttons appear very weirdly when QApplication::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();
    
    JonBJ 1 Reply Last reply
    0
    • M mourke

      I have recently ported my Qt app to macOS and the last bump in the road is that the QMessageBox buttons appear very weirdly when QApplication::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();
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved