How to use the QT graphic view for drawing

im trying to use a QT graphic to draw lines it is possible to draw several objects in a scene, but is it possible to draw (in real time) inside a Qt scene and how? sample code will be highly appreciated
in advance thanks

+3
source share
2 answers

I am creating a kind of "Framework" to do this. There are 2 approaches:

  • Process mouse messages, create a QGraphicsLineItem object , add to the scene, and modify it during the creation process.
  • QGraphicsScene, QGraphicsLineItem, , , drawForeground, .

QGraphicsScene BSP, , , .

+5

1) GraphicsView Scene

m_graphScen = new QGraphicsScene;
m_graphScen->setSceneRect(0,0,790,290);

m_graphView = new QGraphicsView;
m_graphView->setFixedSize(800, 300);
m_graphView->setScene(m_graphScen);

2) , , :

m_graphScen->addLine(0, 250, 700, 250, QPen(QBrush(Qt::black),1));
m_graphView->show();

, , . .

+2

Source: https://habr.com/ru/post/1755706/


All Articles