[Qt]Qt中静态变量的使用方法
Qt中静态变量的使用方法
在头文件中声明静态变量:
static QQueue<QString> _q;
static StaticInstance Instance;
#ifndef STATICINSTANCE_H
#define STATICINSTANCE_H
#include <QObject>
#include "systeminfo.h"
class StaticInstance : public QObject
{
Q_OBJECT
public:
static QQueue<QString> _q;
static StaticInstance Instance;
void logError(const QString& err);
signals:
public slots:
private:
explicit StaticInstance(QObject *parent = nullptr);
};
#endif // STATICINSTANCE_H



