E
E
Egorithm2020-06-05 10:54:22
Qt
Egorithm, 2020-06-05 10:54:22

Qt. How to combine mouseMoveEvent and mousePressEvent events?

It is necessary to draw a rectangle (I was going to do this by calling paintEvent) while holding down the left mouse button, and after releasing it, place this rectangle in a vector.

It is clear that for clamping - mousePressEvent, for tracking movement - mouseMoveEvent, and for releasing - mouseLeaveEvent (I enabled mouseTracking). The question is, how do I combine the actions of these events? After all, you need to draw not when moving, and not when clamping, but when clamping and moving at the same time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacob E, 2020-06-05
@EgoRusMarch

There are two great things in programming - the boolean flag and the conditional operator. Their combination makes it possible to solve this problem. These are the very basics.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question