PDA

View Full Version : How to drag a qwidget horizontally (or vertically)



ilariari
11th May 2015, 11:24
Hallo, I have to realize an horizontally draggable widget.

Such widget implements a cursor which should be movable along the x-axis of a custom painted plot: it's y-position is fixed, only the x- can be varied on the base of drag actions executed by the user.

Following the example given at http://doc.qt.io/qt-4.8/qt-draganddrop-draggableicons-example.html I realized a draggable widget, my difficult is to limit its movements.

When the event dragMoveEvent is called, the draggable widget has already been redrawn and the QDragMoveEvent *event takes inside the new position: ignoring the event isn't helpful to avoid drawing the draggable widget outside a certain coordinates range during dragging. Neither reimplement the mouseMoveEvent is helpful, as it's apparently not called during dragging.

Does anybody give me a suggestion?

Thank you sooo much!