Skip to content

Commit

Permalink
feat: Set QTextEdit to the space width by pressing the tab key
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoth committed Sep 18, 2023
1 parent 23f76a7 commit 9afed48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/QJsonSchemaWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ void QJsonSchemaString::processSchema(const QJsonObject &schema)
// 多行文本
if (uiWidget == "text") {
auto *textEdit = new QTextEdit(this);

QFontMetrics metrics(textEdit->font());
textEdit->setTabStopDistance(4 * metrics.averageCharWidth());

connect(textEdit, &QTextEdit::textChanged, [this]() { Q_EMIT changed(); });
_widget = textEdit;
layout()->addWidget(_widget);
Expand Down

0 comments on commit 9afed48

Please sign in to comment.