一、 支持点击任务栏图标可以放大缩小
this->setWindowFlags(Qt::Window|Qt::FramelessWindowHint |Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
二、支持捕获任务栏图标事件
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#ifdef WIN32
#include <Windows.h>
#endif
bool LoadWnd::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
#ifdef WIN32
MSG *msg = (MSG *)message;
if (msg->message == WM_CLOSE)
{
if(QMessageBox::Yes == QMessageBox::critical(this, tr(u8"警告"), tr(u8"确定退出加载程序吗?"),
QMessageBox::Yes, QMessageBox::No))
{
qApp->exit();
}
}
#endif
return QWidget::nativeEvent(eventType, message, result);
}
三、对于无边框对话框,如果通过任务栏关闭得,将无法再次打开;原因不明,规避措施可以是使用上述方法捕获关闭时间,然后不做处理,也就是无法通过任务栏关闭对话框