在循环中附加值
Append a value in for-loop
我在qpolygonf值的附加/增量中有一个问题:我将一些点推入其中,然后将其连续得出,然后将点上的积分发送到其他类。
...
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)...
谢谢!
如果您想连续增量执行以下操作。
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);
相关文章:
- 如何循环打印顶点结构
- 如何在C++中从两个单独的for循环中添加两个数组
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 正在尝试了解输入验证循环
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 循环后如何继续阅读
- Ardunio UNO解决了多个重叠的定时器循环
- Eigen如何在容器循环中干净地附加矩阵
- 在某些循环内使用vector.push_back时出现分段错误
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- 为什么我的for循环不能正确获取argv
- 如何声明特征矩阵,然后通过嵌套循环初始化它
- while循环中while循环的时间复杂度是多少
- C++中的高效循环缓冲区,它将被传递给C样式数组函数参数
- 为什么在这个代码结束循环中没有得到结束
- 在基于范围的for循环中使用结构化绑定声明
- 用于C++中带有数组和指针的循环
- 循环中的随机函数
- 是什么阻止DOMTimerCoordinator::NextID进入无休止的循环
- 在循环中附加值