H
H
Hipsana2020-06-03 01:49:11
Qt
Hipsana, 2020-06-03 01:49:11

How to draw a triangle in Qt C++?

I work in Qt with the function of drawing shapes.
Please tell me how to draw a triangle and what coordinate formulas it should have in brackets if:

drawLine( lastPoint, endPoint ); this is me drawing the line

drawEllipse( lastPoint, endPoint.x( ) - lastPoint.x( ), endPoint.y( ) - lastPoint.y( )); I draw an ellipse

drawRect( lastPoint.x( ), lastPoint.y( ), endPoint.x( ) - lastPoint.x( ), endPoint.y( ) - lastPoint.y( )); I draw a rectangle

, but the brains do not reach the triangle !!
PS lastPoint - the point where the mouse was pressed on the widget. endPoint.x( ) - end point when stretching a shape (as in Paint)
PS I do it through mouseMoveEvent, mousePressEvent and so on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xibir, 2020-06-03
@xibir

drawPolygon - pass an array of 3 points and there will be a triangle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question