QGraphicsScene addRect 不正确的渲染
QGraphicsScene addRect incorrect render
我在程序中使用带有附加QGraphicsScene的QGraphicsView小部件。这部分工作得很好:
std::vector<unsigned int> nodesCoordsOnScreen;
for(int i=0; i<nodesCoords.size(); i++)
{
unsigned int tempCoord = spaceH+nodesCoords.at(i)*perOneMmH;
graphVW->scene()->addEllipse(tempCoord, -4, 8, 8, standartPen);
QGraphicsTextItem* tempText = graphVW->scene()->addText(QString::number(i+1));
tempText->setPos(tempCoord+8, 0);
graphVW->scene()->addEllipse(tempCoord+8, 5, 15, 15, standartPen);
nodesCoordsOnScreen.push_back(tempCoord);
}
这有麻烦:
for(int i=0; i<bars->rowCount(); i++)
{
unsigned int begin = barsCoords.at(i).first;
unsigned int end = barsCoords.at(i).second;
unsigned int begCrd = nodesCoordsOnScreen.at(begin-1);
unsigned int endCrd = nodesCoordsOnScreen.at(end-1);
graphVW->scene()->addRect(begCrd+4, (barsAreas.at(i)/2)*perOneMmV, endCrd-begCrd,
-(barsAreas.at(i))*perOneMmV, standartPen);
}
麻烦很奇怪:当第二部分渲染时 - 它渲染不正确,但如果我移动程序窗口或最小化它并返回正常状态 - 它呈现正确。
只需要在绘图后使用 QtGraphicsScene::update()。
相关文章:
- 使用2个键的cpp-stl::优先级队列排序不正确
- 正弦级数方程计算不正确
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 密码登录程序将永远循环并显示不正确的结果
- 在C++中返回不正确的楼层函数值
- 形状对象的旋转和缩放不正确C++
- C++ 读取文件读取文件不正确
- 关于类的 Python 文档 - 对C++的引用不正确
- 特征 LLT 模块给出不正确的结果?
- glibcxx STL 在实现 std::valarray::sum() 时是否不正确?
- 如果语句逻辑不正确
- 来自逆 vp 矩阵和相机位置的光线方向不正确
- 不正确的操作数类型 MSVC
- 数组填充了不正确的值
- 我是否不正确地集中了这些字符数组?
- 为什么除非我使用 cout,否则我的值不正确?
- 计算幂级数的数学结果不正确
- 为什么 sizeof 在 C++ 中给出不正确的字节数?
- atoi() 在应用于大型命令行参数时会产生不正确的值
- QGraphicsScene addRect 不正确的渲染