The QMessageBox Dialog Box

Learn about our first dialog box - QMessageBox.

We'll cover the following

Often, a dialog box will appear and present crucial information if a user is about to exit an application, save their work, or if an issue happens. The user can then respond to the prompts in that dialog box, often by clicking a button. The QMessageBox dialog box can be used not only to notify the user of a problem but also to provide them with the option to choose how to respond to it. For instance, you might get a dialog box asking you to "Save", "Don't Save", or "Cancel" when you close a document to which you've recently made changes.

Using the QMessageBox

In the code below, we will look at how to use two of the basic QMessageBox message types, Question and Information, which create a modal dialogue box.

We start by importing the modules that we need.

Get hands-on with 1400+ tech skills courses.