diff options
-rw-r--r-- | src/mainwin.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index 5b986b1..8c21b20 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -75,6 +75,7 @@ #include <QSettings> #include <QProgressDialog> #include <QMutexLocker> +#include <QScrollBar> #include <fstream> @@ -605,7 +606,15 @@ void MainWindow::refreshDocument() reader.setCodec("UTF-8"); QString text = reader.readAll(); PRINTB("Loaded design '%s'.", this->fileName.toLocal8Bit().constData()); + int y = editor->verticalScrollBar()->sliderPosition(); + // Save current cursor position + QTextCursor cursor = editor->textCursor(); + int n = cursor.position(); editor->setPlainText(text); + // Restore cursor position + cursor.setPosition(n); + editor->setTextCursor(cursor); + editor->verticalScrollBar()->setSliderPosition(y); } } setCurrentOutput(); |