#include "mainwindow.h" #include #include #include #include //日志 #include #include "logmsg.h" int main ( int argc, char *argv[] ) { QApplication a(argc, argv); LogMsg::Create(LogMsg::LogMsgType::DebugMsg); MainWindow w; auto fun = [&w](std::string time,std::string msg) { // w.getMsg(time, msg); }; //LogMsg::set_key_callback(fun); logDebug(QString::fromUtf8("软件启动").toStdString().c_str()); //检测是否已运行 QSystemSemaphore sema("monkey", 1, QSystemSemaphore::Open); sema.acquire(); QSharedMemory mem("EVE984"); if (mem.create(1) == false) { logDebug(QString::fromUtf8("本机已经运行一个实例,不能重复运行!").toStdString().c_str()); sema.release(); //程序直接退出 exit(0); } else { sema.release(); w.initWidget(); w.show(); return a.exec(); } }