Sometimes, you need to notify a user when an issue is detected, which might lead to problems if the user continues. This situation calls for a warning dialog, which we will demonstrate in this recipe.
Open the QGIS Python Console by going to the Plugins menu and selecting Python Console.
In this recipe, we will create a dialog, set the warning message and a warning icon, and display the dialog, as follows:
from PyQt4.QtGui import *
msg = QMessageBox()
msg.setText("This is a warning...")
2
:msg.setIcon(QMessageBox.Warning)
msg.show()