ToddAtWSU
20th December 2013, 20:21
I have a class where I declare some public static const QColors in my .h file:
class myClass
{
public:
...
static const QColor GREEN;
static const QColor BLUE;
static const QColor RED;
static const QColor ORANGE;
...
}
Then at the top of my .cpp file, I have:
const QColor myClass::GREEN = QColor(0, 204, 0);
const QColor myClass::BLUE = QColor(0, 102, 255);
const QColor myClass::RED = QColor( 255, 0, 0);
const QColor myClass::ORANGE = QColor(255, 153, 0);
Later, in a function inside myClass, when I try to say:
QColor newColor = myClass::GREEN; // Also tried QColor newColor = GREEN;
qDebug( ) << newColor;
It prints out that newColor is "QColor(Invalid)"
What is wrong with declaring these QColors this way?
class myClass
{
public:
...
static const QColor GREEN;
static const QColor BLUE;
static const QColor RED;
static const QColor ORANGE;
...
}
Then at the top of my .cpp file, I have:
const QColor myClass::GREEN = QColor(0, 204, 0);
const QColor myClass::BLUE = QColor(0, 102, 255);
const QColor myClass::RED = QColor( 255, 0, 0);
const QColor myClass::ORANGE = QColor(255, 153, 0);
Later, in a function inside myClass, when I try to say:
QColor newColor = myClass::GREEN; // Also tried QColor newColor = GREEN;
qDebug( ) << newColor;
It prints out that newColor is "QColor(Invalid)"
What is wrong with declaring these QColors this way?