Qt-creator's bug?
-
hi
Qt::darkGray is an enum / int.
So hence the the error. -
Hi
I think what you want is
if (col == QColor(Qt::white) )
if (col == QColor(Qt::green) )that should work.
-
@mrjj
QColor has the convert function http://doc.qt.io/qt-5/qcolor.html#QColor-1So I can just usecolor == Qt::white
, their data types will convert to each other implicitly.But qt-creator detectscolor == Qt::white
is right,Qt::white == color
is wrong. -
In addition to what @mrjj is telling, there is concept called operator overloading in c++. I'm sure you aware of that. Following statement works
color == Qt::white
because QColor class has '=' (operator) overloaded. Look at the following function signature.
QColor & operator=(Qt::GlobalColor color)
Where as there as there is no operator overaloading for (Qt::white == color )
Hence it does not work. -
@dheerendra
Hi
but is that not the assignment operator it has an overload of ?
And not the == (compare) operator ? -
@mrjj both = and == are overloaded. In the current case it is ==.
-
@dheerendra
Ah i missed that part :)