diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 5733278104af4fb95aef21cb6b26ec29f481f686..23661a796fbc4980ebcf87878a147b96852228ee 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -5482,8 +5482,13 @@ void BaseTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
 void BaseTextEditorWidget::setTabSettings(const TabSettings &ts)
 {
     d->m_document->setTabSettings(ts);
-    int charWidth = QFontMetrics(font()).width(QChar(' '));
-    setTabStopWidth(charWidth * ts.m_tabSize);
+
+    // Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it
+    // to be set as an int. A work around is to access directly the QTextOption.
+    qreal charWidth = QFontMetricsF(font()).width(QChar(' '));
+    QTextOption option = document()->defaultTextOption();
+    option.setTabStop(charWidth * ts.m_tabSize);
+    document()->setDefaultTextOption(option);
 }
 
 void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds)