From 24fc61857cd7ef94de90ae97eb98b44d56ef2679 Mon Sep 17 00:00:00 2001 From: Leandro Melo Date: Mon, 31 Oct 2011 13:37:23 +0100 Subject: [PATCH] Editor: Support floating point values for tab stop Task-number: QTCREATORBUG-833 Change-Id: I76a4b69d6e9402f045a98712531475aff5e8d0ac Reviewed-by: Eike Ziller --- src/plugins/texteditor/basetexteditor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 5733278104a..23661a796fb 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)