From 8903703064761709e4a8fdd6b2fc4657a52daa22 Mon Sep 17 00:00:00 2001 From: "G.K.MacGregor" Date: Sun, 9 May 2021 16:34:53 +0100 Subject: [PATCH] Scroll view to follow cursor --- mainwidget.h | 1 + mainwindow.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/mainwidget.h b/mainwidget.h index e195b25..5c61bd0 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -113,6 +113,7 @@ class LevelOneScene : public QGraphicsScene public: LevelOneScene(QWidget *, QObject *parent = nullptr); void setBorderDimensions(int, int, int, int, int); + QGraphicsRectItem *cursorRectItem() const { return m_cursorRectItem; } public slots: void updateCursor(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 6e7eef4..c9d231f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -925,6 +925,7 @@ void MainWindow::updateCursorPosition() { m_cursorPositionLabel->setText(QString("Row %1 Column %2").arg(m_textWidget->document()->cursorRow()).arg(m_textWidget->document()->cursorColumn())); m_textScene->updateCursor(); + m_textView->ensureVisible(m_textScene->cursorRectItem(), 16, 24); } void MainWindow::updatePageWidgets()