adjust scrollbars for hand moving

This commit is contained in:
itsmattkc
2019-04-09 21:32:21 +10:00
parent 7cbcb20543
commit a4ff6f3b41
+3 -6
View File
@@ -17,7 +17,7 @@ NodeView::NodeView(QGraphicsScene *scene, QWidget *parent) :
void NodeView::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::RightButton) {
if (event->button() == Qt::MidButton) {
hand_moving_ = true;
drag_start_ = event->pos();
} else {
@@ -28,13 +28,10 @@ void NodeView::mousePressEvent(QMouseEvent *event)
void NodeView::mouseMoveEvent(QMouseEvent *event)
{
if (hand_moving_) {
//QPointF scene_delta = mapToScene(event->pos() - drag_start_) - mapToScene(0.0, 0.0);
//emit ScrollChanged(scene_delta.x(), scene_delta.y());
QPoint delta = event->pos() - drag_start_;
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + delta.x());
verticalScrollBar()->setValue(verticalScrollBar()->value() + delta.y());
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - delta.x());
verticalScrollBar()->setValue(verticalScrollBar()->value() - delta.y());
drag_start_ = event->pos();
} else {