Unsolved DrawLine using QPaintedItem is not proper
-
Hi ,
I am trying to draw wave forms using QPaintedItem with drawLine .
When i try to draw continuous line with real time data i can see some pixels are getting missed .With same data if i draw using charview (lineseries,valueAxis) drawing is perfect.
can somebody help what can be issue ? Should i set anything before drawing ?
I am using QPen to draw right now .
Thanks in advance .
-
Hi
Its hard to guess at with no code but
maybe its due to double to int capping and not doing rounding.Can you show your draw code ?
-
void DrawGraph::updateGraph(qreal x, qreal y)
{
QPointF newpoint(xPlotPosition,yPlotPosition);
line = QLineF(lastPoint, newpoint);
lastPoint = newpoint;rect.setRect(newpoint.x()-2,yGraphStartPixel,30,this->height()); update(rect);
}
void DrawGraph::paint(QPainter *painter)
{
this->drawGraph(painter);
}void DrawGraph::drawGraph(QPainter *painter)
{
painter->setPen(QPen(Qt::green,2));painter->drawLine(line); // QLineF line;
}
-
Hi
Seems fine
what types are xPlotPosition,yPlotPosition ? -
xPlotPosition and yPlotPosition are qreal type
-
I would inspect newpoint.x() and see how much its truncated
comapred to the xPlotPositionAlso maybe turn on antialiasing for QPainter
but it really looks like it get truncated.