#include <QApplication>
#include <QLabel>
#include <QMessageBox>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
// Step 1: Create a main window
QLabel mainWindow("Main Window");
mainWindow.show();
// Step 2: Create a popup window using QMessageBox
QMessageBox popup;
popup.setWindowTitle("Popup Window");
popup.setText("This is a popup window!");
// Step 3: Set the buttons in the popup window
popup.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
// Step 4: Customize the appearance and behavior of the popup window
popup.setIcon(QMessageBox::Information);
popup.setDefaultButton(QMessageBox::Ok);
// Step 5: Execute the popup window and wait for user interaction
int result = popup.exec();
// Step 6: Process the user's choice
switch (result) {
case QMessageBox::Ok:
// User clicked the "Ok" button
break;
case QMessageBox::Cancel:
// User clicked the "Cancel" button
break;
default:
// Handle unexpected case
break;
}
// Step 7: Execute the application event loop
return app.exec();
}