PDA

View Full Version : Two Brush styles for single rectitem



PHANI
12th March 2012, 08:55
hi,can some one please tell me i just want my QGraphicsRectItems background should be blue color and top of that one i want the "BDiagPattern"..with my code i am getting only pattern inside the rectitem i want color also ...plese tell me how to do it?



QBrush brush;
brush.setStyle(Qt::BDiagPattern);
QMatrix myMatrix(99,0,99,0,0,0);
brush.setMatrix(myMatrix);
foreach(QGraphicsItem *item ,Parentrect->childItems())
{
qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (Qt::blue));
qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (brush);
}

MarekR22
12th March 2012, 09:35
QBrush brush(Qt::blue, Qt::BDiagPattern);
brush.setMatrix(QMatrix().scale(99,99));
foreach(QGraphicsItem *item ,Parentrect->childItems())
qgraphicsitem_cast <QGraphicsRectItem * >(item)->setBrush (Qt::blue));

PHANI
12th March 2012, 10:13
sorry Marek, it showing only blue color .pattern is not displaying

Spitfire
13th March 2012, 16:30
It's not supported out of a box.

Subclass QAbstractGraphicsShapeItem or QGraphicsRectItem and reimplement paint().
Rememebr to change composition mode when drawing using second brush.