QMessageBox::critical do not show title text
You are doing nothing wrong. From QMessageBox::setWindowTitle
documentation:
Sets the title of the message box to title. On Mac OS X, the window title is ignored (as required by the Mac OS X Guidelines).
It's true that the OS X Human Interface Guidelines say that an alert dialog should have no title. However, that's not the entire story.
For one thing, there's the NSAlert::alertWithMessageText function, which still supports showing a title.
Also, on Apple's own HI Guidelines page, under the section "About Windows," it says that an About window "Has a title bar with no title." However, right above that statement, the example picture of an About box from the Finder very clearly has a title which reads, "About Finder," and in fact, the About box actually does have a title when you click "About Finder."
So Apple's own guidelines in this regard are contradictory.
Therefore, it seems to me that there's nothing really so bad about showing a window title in an alert dialog. (There's also nothing in the guidelines that says you can't create an arbitrary modal window which happens to have a title, a custom icon, a bit of static text, and an OK button.)
To paraphrase Captain Barbossa, like the Pirate Code, the Human Interface Guidelines are just that; they're more "guidelines" than actual rules.
Anyway, here's how you can get a title to show up in your QMessageBox on Mac:
QMessageBox msgBox("", "Text", QMessageBox::Critical, 0, 0, 0, nullptr, Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
msgBox.QDialog::setWindowTitle("My Title");
msgBox.exec();
I also call msgBox.setAttribute(Qt::WA_MacFrameworkScaled) in my app, which is using a slightly older version of Qt which does not want to support high-res Retina displays in QMessageBox by default.
On the other hand, there are circumstances on Mac where a sheet modal dialog (with no title bar) is more appropriate, and Qt supports this by calling QWidget::setWindowModality(Qt::WindowModal), and obviously a non-null parent window is required.