Hi!

I derived from QGraphicsItem and I would like to be able to perfom some freehand painting.

For normal pens, this is not a problem, I manage a QImage and in my mouseReleaseEvent, I draw lines from one to the next event position:

Qt Code:
  1. void GraphicsHairstyleItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
  2. {
  3. QPainter p( &backgroundImage );
  4. QPen pen;
  5. pen.setWidth(30);
  6. pen.setColor(Qt::red);
  7. p.setPen(pen);
  8. p.drawLine(event->lastPos(),event->pos());
  9. p.end();
  10. }
To copy to clipboard, switch view to plain text mode 

The question now is:

How can I use a pen which is "diffuse" at the boundary, ie. a radial gradient whose alpha-component goes to 0 at the outside ???

I know that I could get a QRadial Gradient as QBrush like
Qt Code:
  1. QRadialGradient gradient(15, 15, 15, 15, 15);
  2. gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1, 1));
  3. gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1, 0));
  4. QBrush b(gradient);
To copy to clipboard, switch view to plain text mode 

this does not work and as far as I know, brushes are used for filling, not for the outlines.

Appreciate any help!

Thanks a lot!!!

Olli