在main函数里添加内容
#include <windows.h>
HANDLE hMutex = CreateMutex(NULL, true, QString("SoftwareString").toStdWString().c_str());
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hMutex);
QMessageBox::information(NULL,"提示","程序已经打开过了");
a.exit(1);
return 1;
}