diff --git a/graphicsview.cpp b/graphicsview.cpp index b8c6629..05a089b 100644 --- a/graphicsview.cpp +++ b/graphicsview.cpp @@ -19,6 +19,9 @@ GraphicsView::GraphicsView(QWidget *parent) "border-radius: 3px;"); setAcceptDrops(true); setCheckerboardEnabled(false); + + connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged); + connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged); } void GraphicsView::showFromUrlList(const QList &urlList) @@ -243,17 +246,6 @@ void GraphicsView::dropEvent(QDropEvent *event) } } -void GraphicsView::paintEvent(QPaintEvent *event) -{ - // A little dirty hack way to get the viewport "pan" event - // but still doesn't works well with gif which scaled up bigger than the window. - if (event->rect() == this->rect() && !isThingSmallerThanWindowWith(transform())) { - emit viewportRectChanged(); -// qDebug() << "paintEvent" << event << QObject::sender(); - } - return QGraphicsView::paintEvent(event); -} - bool GraphicsView::isThingSmallerThanWindowWith(const QTransform &transform) const { return rect().size().expandedTo(transform.mapRect(sceneRect()).size().toSize()) diff --git a/graphicsview.h b/graphicsview.h index 168820d..f216752 100644 --- a/graphicsview.h +++ b/graphicsview.h @@ -49,8 +49,6 @@ private: void dragMoveEvent(QDragMoveEvent *event) override; void dropEvent(QDropEvent *event) override; - void paintEvent(QPaintEvent *event) override; - bool isThingSmallerThanWindowWith(const QTransform &transform) const; bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const; void setCheckerboardEnabled(bool enabled);