我对QPolygonF值的append / incrementg有一个问题:我将一些点推入其中,我不断得到它,然后通过信号将点发送到其他类。
...
QPolygonF points;
for(int i= 0; i< 5; ++i)
{
double value= finalMat.at<double>(i);
points.push_back(QPointF((double)i, value));
//points << QPointF((double)i, value);
}
qDebug()<<"points: " << points;
emit updatePointsSignal(points);
上面的代码块在达到条件编号后删除旧点,并使用新索引发送5个新点。输出是:
points: QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue) QPolygonF(0, newPointValue) QPolygonF(1, newPointValue)...
如何在不删除旧点的情况下递增我的点并发送它们,以便输出看起来像?
points: QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue) QPolygonF(5, newPointValue) QPolygonF(6, newPointValue) QPolygonF(7, newPointValue) QPolygonF(8, newPointValue)...
谢谢!
答案 0 :(得分:0)
该程序正在按照您的要求进行操作!如果您想要连续增量,请执行以下操作。
QPolygonF points;
static int indx = 0;
for(int i= 0; i< 5; ++i)
{
double value= finalMat.at<double>(i);
indx += i;
points.push_back(QPointF((double)indx, value));
}
qDebug()<<"points: " << points;
emit updatePointsSignal(points);