diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2011-10-31 13:37:23 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-10-31 14:57:04 +0100 |
commit | 24fc61857cd7ef94de90ae97eb98b44d56ef2679 (patch) | |
tree | b179ce80da9202b088f1f9220085137c27c1671f /src/plugins/texteditor | |
parent | 19ea22a2acd29bc02b029be8eacb54405f4a517a (diff) | |
download | qt-creator-24fc61857cd7ef94de90ae97eb98b44d56ef2679.tar.gz |
Editor: Support floating point values for tab stop
Task-number: QTCREATORBUG-833
Change-Id: I76a4b69d6e9402f045a98712531475aff5e8d0ac
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/basetexteditor.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 5733278104..23661a796f 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) |