Qt中点击关闭任务栏而不退出程序的实现方法

// 重新覆写关闭事件响应函数

protected:

virtual void closeEvent(QCloseEvent *event);

void MyWidget::closeEvent(QCloseEvent *event)
{
	qDebug() << "widget will close, but app done not quit";
	event->ignore(); // 忽略关闭事件
	hide();   // 只是隐藏窗口
}


猜你喜欢

转载自blog.csdn.net/e5max/article/details/76422651