QT QGraphicsView 画线

来源:互联网 发布:gps nema 数据解析 编辑:程序博客网 时间:2024/06/04 18:35

QT

 QGraphicsScene scene; scene.addText("Hello, world!"); QGraphicsView view(&scene); view.show();

GraphicsScene *scene () const//通过函数返回scene

Returns a pointer to the scene that is currently visualized in the view. If no scene is currently visualized, 0 is returned.

See also setScene().


std::vector<QGraphicsLineItem*> _xItem;

第一步//把线条添加到Vector 数组

for (int i = 0; i <i; ++i)

{

_yRect.push_back(scene->addLine(0,0,0,0,Normal_First_Circle_Pen);//把线条添加到Vector 数组
}

第二步//设置项的画线
for (int i = 0; i <i; ++i)

{

_xItem;[i]->setRect(x, (gap)*i, posA, yh);

}