, ? ? ? , . : , .
#include ...
class QUpdatingPathItem : public QGraphicsPathItem {
void advance(int phase) {
if (phase == 0)
return;
int x = abs(rand()) % 100;
int y = abs(rand()) % 100;
QPainterPath p = path();
p.lineTo(x, y);
setPath(p);
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene s;
QGraphicsView v(&s);
QUpdatingPathItem item;
item.setPen(QPen(QColor("red")));
s.addItem(&item);
v.show();
QTimer *timer = new QTimer(&s);
timer->connect(timer, SIGNAL(timeout()), &s, SLOT(advance()));
timer->start(1000);
return a.exec();
}
- :

QGraphicsPathItem, , . , -, , ( , QPainterPath ...)
QPainterPath p = gPath.path();
p.lineTo(0, 42);
gPath.setPath(p);
, - / . Qt . QGraphicsPathItem, advance(), . , , s.advance() .
http://doc.trolltech.com/4.5/qgraphicsscene.html#advance