Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
None
-
4.6.0
-
None
-
Windows XP Pro 2002 SP3
Description
I wanna draw a rect with a given pen color and a text with the same pen color
Here is a piece of code I use do do this, in the paint method of my QGraphicsItem
void myGraphicsItem::paint( QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/ ) { int alpha = 60; QColor penColor(83,93,111,alpha); painter->setPen(penColor); painter->drawRect(myRect); painter->drawText(myTextPosition, QString( "My Text" )); }
The text is drawn in strong black, with no transparency
Adding the following code before the drawTextprovides the same effect :
// Provide another pen with the same color
QColor penColor2(83,93,111,alpha);
painter->setPen(penColor2);
Finally providing a new pen with another color has the expected effet :
// Here, we change only the red component from 83 to 80 for example
QColor penColor2(80,93,111,alpha);
painter->setPen(penColor2);