Answer the question
In order to leave comments, you need to log in
How to implement adding point to QGraphicsView?
Hello. Started learning Qt. There was such a question. Wrote a simple program that displays a lot of points on QGraphicsView. While I add all the points in the code itself through initialization.
void Graphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
std::vector<QPointF> points = {{10, 20}, {-30, 30}, {-40, 20}, {-50, 0}, {-60, 20}, {-75, 25},
{-20, 10}, {-30, 15}, {25, 40}, {35, 35}, {50, 40}, {60, 70}};
QPen pen(Qt::red, 4);
painter->setPen(pen);
for(auto& it = points.begin(); it != points.end(); ++it){
painter->drawPoint(*it);
}
Q_UNUSED(option);
Q_UNUSED(widget);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question