设置QTextEdit的Tab跳过的空格数为4个空格

This commit is contained in:
sonichy 2018-07-13 15:49:47 +08:00
parent 63f83d276e
commit 8084372f00
3 changed files with 6 additions and 3 deletions

BIN
HTYEdit

Binary file not shown.

View File

@ -184,7 +184,7 @@ void MainWindow::on_action_save_triggered()
if (path == "") {
on_action_saveas_triggered();
} else {
MdiChild *child = (MdiChild*)(ui->mdiArea->currentSubWindow()->widget());
MdiChild *child = (MdiChild*)(ui->mdiArea->currentSubWindow()->widget());
if (child->save()) {
LS1->setText("保存 " + child->path);
}

View File

@ -11,7 +11,10 @@
#include <QProcess>
MdiChild::MdiChild()
{
{
QFontMetrics FM(font());
int ts = 4;
setTabStopWidth(ts * FM.boundingRect("*").width());
connect(document(),SIGNAL(contentsChanged()),this,SLOT(onContentsChanged()));
}
@ -63,7 +66,7 @@ bool MdiChild::loadFile(QString filename)
Highlighter *highlighter = new Highlighter(document());
Q_UNUSED(highlighter);
showMaximized();
zoomIn(4);
zoomIn(4);
return true;
}else{
QMessageBox::warning(this,"错误", QString(" %1:\n%2").arg(path).arg(file->errorString()));