-3
如何在任务栏中打开QDialog
窗口而不是QuitProgram,当我在CloseWindow中单击右键时?如何在任务栏中打开QDialog窗口而不是CloseWindow
支票影像
观测数据:我已经有一个了QDialog UI与按钮退出程序。
如何在任务栏中打开QDialog
窗口而不是QuitProgram,当我在CloseWindow中单击右键时?如何在任务栏中打开QDialog窗口而不是CloseWindow
支票影像
观测数据:我已经有一个了QDialog UI与按钮退出程序。
覆盖主窗口中的QWidget::closeEvent()
函数。当用户尝试退出应用程序时会调用这个函数。例如:
void YourMainWindow::closeEvent(QCloseEvent* ev)
{
QMessageBox msgBox(QMessageBox::Question,
tr("Quit"), tr("Are you sure you want to quit?"),
QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
#ifdef Q_OS_MAC
// This presents the dialog as a sheet in Mac OS.
msgBox.setWindowModality(Qt::WindowModal);
#endif
if (msgBox.exec() == QMessageBox::Yes) {
ev->accept();
} else {
ev->ignore();
}
}
非常感谢,非常有帮助! –