Hello,

I'm using QPainterPath to draw a curve on a QGraphicsView (this should be a graph later), and now I find it possible that I'm on a wrong way.

Here is the result (concentrate on the blue thing):

This is surely not what I meant.
The black sinus dots a bit below works fine, but these are just dots, not a smooth line.
Furthermore when I want to use the shortcut for the button, by pressing the "Alt" the image redraws the path, and I don't really understand what happens. I mean I gues by pressing Alt it redraws each item sent to the GraphichsView, but what does it draw now? The second one is this:


Well, I'm "simply" searching for the solution, any ideas are welcome.

this is the reimplementation of the paint function: (anyway, this was meant to have a hole in the middle, which now I find possible that it not possible with QPainterPath)
related declarations:

int maxDataNum;
QPainterPath qpp;
QPointF * qpf; ... later qpf = new QPointF[maxDataNum]; when it is set.


Qt Code:
  1. void pathGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  2. {
  3. int i;
  4. for( i = 1; i < maxDataNum; i++)
  5. {
  6. if(!qpf[i-1].isNull() && !qpf[i].isNull())
  7. {
  8. qpp.quadTo(qpf[i-1],qpf[i]);
  9. }
  10.  
  11. }
  12.  
  13. painter->setBrush(Qt::blue);
  14. painter->drawPath(qpp);
  15. }
To copy to clipboard, switch view to plain text mode