Originally Posted by
MarkoSan
Yes, but I need a variable that will be seen to all objects in an application, not just one object/class.
Try something like this
//GlobalClass.h
// forward declaration
class GlobalClass;
// global GlobalClass object
// there must only be one of these per application (like qApp)
// defined and initialized in GlobalClass.cpp
extern GlobalClass *chemGlobals;
{
Q_OBJECT
public:
GlobalClass(int var = default){}
virtual ~GlobalClass(){}
private:
int m_val;
};
////GlobalClass.cpp
#include "GlobalClass.h"
// global ChemGlobals object
// there must only be one of these per application (like QApp)
ChemGlobals * chemGlobals = 0;
//GlobalClass.h
// forward declaration
class GlobalClass;
// global GlobalClass object
// there must only be one of these per application (like qApp)
// defined and initialized in GlobalClass.cpp
extern GlobalClass *chemGlobals;
class GlobalClass : public QObject
{
Q_OBJECT
public:
GlobalClass(int var = default){}
virtual ~GlobalClass(){}
private:
int m_val;
};
////GlobalClass.cpp
#include "GlobalClass.h"
// global ChemGlobals object
// there must only be one of these per application (like QApp)
ChemGlobals * chemGlobals = 0;
To copy to clipboard, switch view to plain text mode
Bookmarks