From a4a5ab37855fccc1cac5e6028d90c8294ea795b9 Mon Sep 17 00:00:00 2001 From: SKiars <2269610337@qq.com> Date: Wed, 24 Jul 2019 21:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=88=E7=AB=AF=E6=8E=A7=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SerialTool/src/views/terminal/qvterminal/qvterminal.cpp | 8 ++++---- SerialTool/src/views/terminal/qvterminal/qvterminal.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/SerialTool/src/views/terminal/qvterminal/qvterminal.cpp b/SerialTool/src/views/terminal/qvterminal/qvterminal.cpp index 223e9ab..f755302 100644 --- a/SerialTool/src/views/terminal/qvterminal/qvterminal.cpp +++ b/SerialTool/src/views/terminal/qvterminal/qvterminal.cpp @@ -259,6 +259,7 @@ void QVTerminal::setFormat(const QVTCharFormat &format) QFontMetrics fm(*_format.font()); _cw = fm.boundingRect('M').width(); _ch = fm.height(); + _cascent = fm.ascent(); } bool QVTerminal::event(QEvent *event) @@ -317,8 +318,7 @@ void QVTerminal::paintEvent(QPaintEvent */* paintEvent */) p.fillRect(viewport()->rect(), QColor(0x23, 0x26, 0x29)); - QPoint pos; - pos.setY(0); + QPoint pos(0, 0); int firstLine = verticalScrollBar()->value() / _ch; int lastLine = viewport()->size().height() / _ch + firstLine; @@ -338,8 +338,8 @@ void QVTerminal::paintEvent(QPaintEvent */* paintEvent */) pos.setX(0); for (auto vtc : _layout->lineAt(l).chars()) { p.setPen(pos == curPos ? vtc.background() : vtc.foreground()); - p.drawText(QRect(pos, QSize(_cw, _ch)), Qt::AlignCenter, vtc.c()); - p.setBrush(QBrush()); + p.drawText(pos.x(), pos.y() + _cascent, vtc.c()); + //p.setBrush(QBrush()); //p.drawRect(QRect(pos, QSize(_cw, _ch))); pos.setX(pos.x() + _cw); } diff --git a/SerialTool/src/views/terminal/qvterminal/qvterminal.h b/SerialTool/src/views/terminal/qvterminal/qvterminal.h index 38f6d63..badd3ec 100644 --- a/SerialTool/src/views/terminal/qvterminal/qvterminal.h +++ b/SerialTool/src/views/terminal/qvterminal/qvterminal.h @@ -62,8 +62,7 @@ protected slots: // cursor QVTCharFormat _format; QVTCharFormat _curentFormat; - int _cw; - int _ch; + int _cw, _ch, _cascent; QPoint _cursorPos; QTimer _cursorTimer; bool _cvisible;