Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QPen in Orange?

Tags:

c++

qt

When it's about to set a Qt Pen in blue, red or green, I can do the following:

QPen(Qt::blue));
QPen(Qt::red));
QPen(Qt::orange));

But when it's about to set an orange color, it's not recognized.

Then, how to set a QPen in orange?

like image 429
MelMed Avatar asked Oct 10 '13 09:10

MelMed


3 Answers

If you look at QColor::setNamedColor(), it states:

Sets the RGB value of this QColor to name, which may be in one of these formats: ... A name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro"...

And here is the list of names you can use.

So you can do this:

QPen pen;
pen.setColor("orange");
like image 82
thuga Avatar answered Oct 28 '22 15:10

thuga


QColor understands SVG colors also (I find handy this graphviz page for reference). Then you can just name it:

QColor c("orange")

The same page also reports actual values: orange is #ffa500

like image 27
CapelliC Avatar answered Oct 28 '22 15:10

CapelliC


You should use one of predefined colors, or create a custom color, for example QPen(QColor( 0xFF, 0xA0, 0x00 ))

like image 25
Dmitry Sazonov Avatar answered Oct 28 '22 14:10

Dmitry Sazonov