Vladimir
Vladimir

Reputation: 155

How to detect a QGraphicsItem moving performing by mouse?

I have a child class of QGraphicsItem with Selectable and Movable flags. When I select many items and moving them, all recieves itemChange event. Is there any way to detect in itemChanged that mouse's button is still pressed?

Upvotes: 1

Views: 678

Answers (1)

vahancho
vahancho

Reputation: 21220

Please refer to the QApplication::mouseButtons() function that will return the current state of the mouse buttons Qt::MouseButtons.

Qt::MouseButtons btns = QApplication::mouseButtons();
if (btns & Qt::LeftButton) {
    // The left button is pressed.
    [..]
}

Upvotes: 3

Related Questions