diff --git a/src/gui/layout/qgslayoutview.cpp b/src/gui/layout/qgslayoutview.cpp index 7add1220a5fd..47b53bf9ce09 100644 --- a/src/gui/layout/qgslayoutview.cpp +++ b/src/gui/layout/qgslayoutview.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #define MIN_VIEW_SCALE 0.05 #define MAX_VIEW_SCALE 1000.0 @@ -67,6 +68,9 @@ QgsLayoutView::QgsLayoutView( QWidget *parent ) connect( this, &QgsLayoutView::zoomLevelChanged, this, &QgsLayoutView::invalidateCachedRenders ); connect( this, &QgsLayoutView::zoomLevelChanged, this, &QgsLayoutView::extentChanged ); + verticalScrollBar()->installEventFilter( this ); + horizontalScrollBar()->installEventFilter( this ); + mScreenHelper = new QgsScreenHelper( this ); } @@ -1301,6 +1305,17 @@ void QgsLayoutView::wheelZoom( QWheelEvent *event ) } } + +bool QgsLayoutView::eventFilter( QObject *object, QEvent *event ) +{ + if ( event->type() == QEvent::MouseButtonRelease ) + { + emit extentChanged(); + } + return QGraphicsView::eventFilter( object, event ); + +} + QGraphicsLineItem *QgsLayoutView::createSnapLine() const { std::unique_ptr< QGraphicsLineItem> item( new QGraphicsLineItem( nullptr ) ); diff --git a/src/gui/layout/qgslayoutview.h b/src/gui/layout/qgslayoutview.h index 249fc39df819..304ca90efc22 100644 --- a/src/gui/layout/qgslayoutview.h +++ b/src/gui/layout/qgslayoutview.h @@ -295,6 +295,11 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView */ void setSectionLabel( const QString &label ); + /** + * Event filter to handle mouse release on scroll bars + */ + bool eventFilter( QObject *object, QEvent *event ) override; + public slots: /**