I have a class where I declare some public static const QColors in my .h file:
class myClass
{
public:
...
...
}
class myClass
{
public:
...
static const QColor GREEN;
static const QColor BLUE;
static const QColor RED;
static const QColor ORANGE;
...
}
To copy to clipboard, switch view to plain text mode
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);
To copy to clipboard, switch view to plain text mode
Later, in a function inside myClass, when I try to say:
QColor newColor
= myClass
::GREEN;
// Also tried QColor newColor = GREEN; qDebug( ) << newColor;
QColor newColor = myClass::GREEN; // Also tried QColor newColor = GREEN;
qDebug( ) << newColor;
To copy to clipboard, switch view to plain text mode
It prints out that newColor is "QColor(Invalid)"
What is wrong with declaring these QColors this way?
Bookmarks