Hi,
Thanks for you help but I cannot get your suggestion to work properly.
I overloaded the paint method for a class derived from qgraphicsitem as you showed but this does not work for me. It seems that the brush pattern matrix does not have any effect at all.
For example:
{
QBrush myBrush
(Qt
::red, Qt
::DiagCrossPattern);
myBrush.setMatrix(myMatrix);
painter->setBrush(myBrush);
painter->drawEllipse(-50, -50, 100, 100);
}
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QBrush myBrush(Qt::red, Qt::DiagCrossPattern);
QMatrix myMatrix(99,0,99,0,0,0);
myBrush.setMatrix(myMatrix);
painter->setBrush(myBrush);
painter->drawEllipse(-50, -50, 100, 100);
}
To copy to clipboard, switch view to plain text mode
produces a shape the looks the same as:
{
QBrush myBrush
(Qt
::red, Qt
::DiagCrossPattern);
QMatrix myMatrix
(1,
0,
1,
0,
0,
0);
//don't scale this time myBrush.setMatrix(myMatrix);
painter->setBrush(myBrush);
painter->drawEllipse(-50, -50, 100, 100);
}
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QBrush myBrush(Qt::red, Qt::DiagCrossPattern);
QMatrix myMatrix(1,0,1,0,0,0); //don't scale this time
myBrush.setMatrix(myMatrix);
painter->setBrush(myBrush);
painter->drawEllipse(-50, -50, 100, 100);
}
To copy to clipboard, switch view to plain text mode
I am using QT4.3.
Am I doing anything wrong here?
I've tried both the Qt:DiagCrossPattern brush and also a custom brush made with a QImage.
Thanks!
Bookmarks