QMessageBox Change Icon

QMessageBox Change Icon

The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. QMessageBox supports four predefined message severity levels, or message types, which really only differ in the predefined icon they each show. Specify one of the four predefined message types by setting the icon property to one of the predefined icons. The following rules are guidelines:

We can modified QMessagebox icon by use either setIcon() for one of the standard icons, or setIconPixmap() for a custom icon. This is a method how to QMessageBox change icon example. From this QMessageBox change icon code, I use setIconPixmap() method with input a png icon file. This is a screenshoot from default QMessageBox window and QMessageBox change icon window :

QMessageBox change iconWe can change QMessageBox Icon with this simple code :

    QMessageBox mb("Show Messagebox",
    "QMessageBox with new Icon?",
    QMessageBox::Yes | QMessageBox::Default,

    QPixmap exportSuccess(":new/icon/New.png");

You can download the complete change QMessageBox Icon source code at here.

Source :

Add a Comment

Your email address will not be published. Required fields are marked *