// wgt.hclass wgt : public QWidget {...private: void paintEvent(QPaintEvent *);...};//wgt.cppvoid wgt::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setPen( QPen(Qt::green,1,Qt::DashLine) ); painter.drawLine(0,0,10,10); painter.drawLine(10,10,10,20); painter.drawLine(10,20,100,15);}
QPainter painter(ui->graphicsView);ui->graphicsView->update();