PDA

View Full Version : Not all colors in QtColor enum are available to me



emp1953
16th June 2017, 00:33
using qtcreator with QT 4.8.5

I am changing widget colors using the code

QPalette pal = button_array[i]->palette();
pal.setColor(QPalette::Button, QColor(Qt::gray));
pal.setColor(QPalette::ButtonText,Qt::black);

I am trying to get the button color back to its original color when it is first displayed.

If I change the color to Qt::lightgray, it thows a compiler error saying that lightgray is not a member of QT

All the documentation shows both light and dark versions of all the colors.

I can only utilize white, yellow, green, red, blue, black, gray, magenta

Any clues as to why the light and dark versions of the colors are throwing compiler errors??

Thanks in advance.

-Ed

d_stranz
16th June 2017, 21:11
Because you have not spelled the names correctly. C++ is case sensitive, remember? Read the docs. (https://doc.qt.io/qt-4.8/qt.html#GlobalColor-enum)

emp1953
17th June 2017, 15:29
a newbie error. Thanks for the help. I wonder if the video driver on my pc is sub-par because there is no difference in color between the lightGray, darkGray, and gray. I'm trying to get back to the original color that QT makes the button when placed on the form.