You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
whellvalue/tpvs17/Enchanter/QSignleApplication.h

47 lines
1.0 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef _H_QSIGNLEAPPLICATION_H_
#define _H_QSIGNLEAPPLICATION_H_
#include <QObject>
#include <QApplication>
class QMainWindow;
class QLocalServer;
class SingleApplication : public QApplication
{
Q_OBJECT
public:
SingleApplication(int &args, char **argv, QString strServerName);
bool getInstanceRunning() const; // 是否已经有实例在运行
QMainWindow *getMainWindow() const;
void setMainWindow(QMainWindow *value);
private slots:
void newLocalConnection();
private:
void initLocalConnection(); // 初始化本地连接
void newLocalServer(); // 创建服务端
bool instanceRunning{ false }; // 是否已经有实例在运行
QLocalServer *localServer{ nullptr }; // 本地socket Server用于本地进程间通信
QString m_serverName; // 服务名称
QMainWindow *mainWindow{ nullptr }; // MainWindow指针
};
/*
Example:
int main(int argc, char *argv[]){
SingleApplication a(argc, argv, "lp_report");
if (!a.getInstanceRunning())
{
slpsf_mark_report w;
a.setMainWindow(&w);
w.show();
return a.exec();
}
return 0;
}
*/
#endif