Working with dialog boxes

One very important aspect of creating a user-friendly application is the ability to display vital information regarding the status of the application when a certain event (intended or unintended) occurs. To display such information, we need an external window that can be dismissed by the user once he/she has acknowledged the information.

Qt comes with this functionality, and it's all residing in the QMessageBox class. There are several types of message box you can use in Qt; the most basic one uses just a single line of code, like so:

QMessageBox::information(this, "Alert", "Just to let you know, something happened!"); 

There are three parameters you need to provide for this function. The first one is the parent ...

Get Hands-On GUI Programming with C++ and Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.