How is possible to display a QMessageBox::warning with the triangular exclamation mark symbol like the one following?

I can't find any option in QMessageBox::warning, I only get the red circular symbol.
You can use the QMessageBox.setIcon() function to configure which symbol you see when the dialog is displayed.
The predefined icon property types are listed here: https://doc.qt.io/qt-5/qmessagebox.html#severity-levels-and-the-icon-and-pixmap-properties
Here is my C++ example of a message box with the yellow triangle icon:
QMessageBox msgWarning;
msgWarning.setText("WARNING!\nRunning low on coffee.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
And here is my C++ example of a message box with the red circle icon:
QMessageBox msgError;
msgError.setText("CRITICAL ERROR!\nThe McRib is no longer available!");
msgError.setIcon(QMessageBox::Critical);
msgError.setWindowTitle("Danger");
msgError.exec();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With