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.
{
int i;
for( i = 1; i < maxDataNum; i++)
{
if(!qpf[i-1].isNull() && !qpf[i].isNull())
{
qpp.quadTo(qpf[i-1],qpf[i]);
}
}
painter->setBrush(Qt::blue);
painter->drawPath(qpp);
}
void pathGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
int i;
for( i = 1; i < maxDataNum; i++)
{
if(!qpf[i-1].isNull() && !qpf[i].isNull())
{
qpp.quadTo(qpf[i-1],qpf[i]);
}
}
painter->setBrush(Qt::blue);
painter->drawPath(qpp);
}
To copy to clipboard, switch view to plain text mode
Bookmarks