Skip to content

Commit aa3008c

Browse files
committed
[Add] Update MainWindow to set tab stop distance for code editor
1 parent c361732 commit aa3008c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/MainWindow.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
1919
editor = new CodeEditor(this);
2020
syntax = new Syntax(editor->document());
2121

22-
createMenuBar();
22+
QFontMetrics metrics(editor->font());
23+
int spaceWidth = metrics.horizontalAdvance(" ");
24+
editor->setTabStopDistance(spaceWidth * 4);
2325

2426
QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
2527
setCentralWidget(splitter);
@@ -31,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
3133
splitter->setSizes(QList<int>() << 20 << 950);
3234
splitter->addWidget(editor);
3335

36+
createMenuBar();
3437
showMaximized();
3538
}
3639

0 commit comments

Comments
 (0)