Hello,
In the application I'm currently developping, I need to access (through setMode and getMode methods), from any classes, to a variable 'mode' that shows in which mode the application is.
I want other classes to be warned about changes of the value of this variables.
That's why I subclasses QApplication.
I cannot though access to this variable, this :
qDebug()<<QApplication_ac::instance()->getMode(); //here, the problem !
give the error :
class QCoreApplication' has no member named 'getMode'
qDebug()<<QApplication_ac::instance()->getMode();
How can I solve my problem ?
Many thanks for answer.
Here is the code :
qapplication_ac.h :
#ifndef QAPPLICATION_AC_H
#define QAPPLICATION_AC_H
#include <QApplication>
enum Mode {NOTHING=0,
PICKING_DETAIL,
PANNING,
ROTATION,
PICKING_POINT,
ABOUT_TO_CLOSE,
POLYGON_FINISHED
};
{
Q_OBJECT
public:
QApplication_ac(int &argc, char *argv[]); //constuctor
Mode mode;
Mode getMode(){ return mode;}
void setMode(Mode modeToSet);
signals:
void modeChanged(Mode newMode,Mode oldMode); //other classes will be connected to this signal
};
#endif // QAPPLICATION_AC_H
#ifndef QAPPLICATION_AC_H
#define QAPPLICATION_AC_H
#include <QApplication>
enum Mode {NOTHING=0,
PICKING_DETAIL,
PANNING,
ROTATION,
PICKING_POINT,
ABOUT_TO_CLOSE,
POLYGON_FINISHED
};
class QApplication_ac:public QApplication
{
Q_OBJECT
public:
QApplication_ac(int &argc, char *argv[]); //constuctor
Mode mode;
Mode getMode(){ return mode;}
void setMode(Mode modeToSet);
signals:
void modeChanged(Mode newMode,Mode oldMode); //other classes will be connected to this signal
};
#endif // QAPPLICATION_AC_H
To copy to clipboard, switch view to plain text mode
qapplication_ac.cpp :
#include "qapplication_ac.h"
QApplication_ac::QApplication_ac(int &argc, char *argv[]):
{
mode=NOTHING;
}
void QApplication_ac::setMode(Mode modeToSet){
emit modeChanged(modeToSet,getMode());
mode=modeToSet;
}
#include "qapplication_ac.h"
QApplication_ac::QApplication_ac(int &argc, char *argv[]):
QApplication(argc, argv)
{
mode=NOTHING;
}
void QApplication_ac::setMode(Mode modeToSet){
emit modeChanged(modeToSet,getMode());
mode=modeToSet;
}
To copy to clipboard, switch view to plain text mode
Bookmarks