How to create a window Qt behaves like a message box?

I want to create a Qt popup that will behave like a message box in Qt. This means that the rest of the GUI must be blocked until this popup is fired. It may be a child's question, but can someone help me with this?

Thanks...:)

Edit:

I want to use forms, labels, buttons, and some other types of widgets in this popup.

+6
c ++ qt
source share
1 answer

Modal dialogs

A modal dialog box is a dialog box that blocks input to other visible windows in the same application. Users must finish interacting with the dialog and close before they can access any other windows in the application. Dialogs that are used to request a file name from a user or that are used to set application preferences are usually modal.

The most common way to display a modal is to call the exec () function. When the user closes the dialog, exec () will provide a useful income value. As a rule, in order to get the dialog close and return the corresponding value, we connect the default button, for example, β€œOK”, to the accept () slot and the β€œCancel” button to the reject () slot. Alternatively, you can call done () the slot with the accepted or rejected.

An alternative is to call setModal (true) or setWindowModality (), then show (). Unlike exec (), show () returns control to the caller immediately. Calling setModal (true) is especially useful for progressing dialogs, where the user must have the ability to interact with the dialog, for example, cancel a lengthy operation. If you use show () and setModal (true) together to execute you must call QApplication :: processEvents () periodically during processing to allow the user to interact with the Dialog. (See QProgressDialog.)

+17
source share

All Articles