1 Star 0 Fork 19

gaochang/qt5-qtbase

forked from src-anolis-os/qt5-qtbase 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
QTBUG-95341-Account-for-the-placeholderText-when-computing-lineRect.patch 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
xingwei-liu 提交于 2022-10-13 02:47 . !8 feature: add patchs for DDE
From 8f53d8ced4d81468121ad3dbb469095c2666eb46 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 11:13:27 +0800
Subject: [PATCH]
QTBUG-95341-Account-for-the-placeholderText-when-computing-lineRect
---
src/widgets/widgets/qlineedit.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 9e1d0d23..8227786d 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -2032,21 +2032,28 @@ void QLineEdit::paintEvent(QPaintEvent *)
p.setClipRect(r);
QFontMetrics fm = fontMetrics();
+ int fmHeight = 0;
+ if (d->shouldShowPlaceholderText())
+ fmHeight = fm.boundingRect(d->placeholderText).height();
+ else
+ fmHeight = fm.boundingRect(d->control->text() + d->control->preeditAreaText()).height();
+ fmHeight = qMax(fmHeight, fm.height());
+
Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment));
switch (va & Qt::AlignVertical_Mask) {
case Qt::AlignBottom:
- d->vscroll = r.y() + r.height() - fm.height() - QLineEditPrivate::verticalMargin;
+ d->vscroll = r.y() + r.height() - fmHeight - QLineEditPrivate::verticalMargin;
break;
case Qt::AlignTop:
d->vscroll = r.y() + QLineEditPrivate::verticalMargin;
break;
default:
//center
- d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2;
+ d->vscroll = r.y() + (r.height() - fmHeight + 1) / 2;
break;
}
QRect lineRect(r.x() + QLineEditPrivate::horizontalMargin, d->vscroll,
- r.width() - 2 * QLineEditPrivate::horizontalMargin, fm.height());
+ r.width() - 2 * QLineEditPrivate::horizontalMargin, fmHeight);
if (d->shouldShowPlaceholderText()) {
if (!d->placeholderText.isEmpty()) {
--
2.31.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gcdota930915/qt5-qtbase.git
git@gitee.com:gcdota930915/qt5-qtbase.git
gcdota930915
qt5-qtbase
qt5-qtbase
a8

搜索帮助