adjust scrollbars for hand moving
This commit is contained in:
+3
-6
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user