Skip to content

Commit

Permalink
fix: PlaceholderText is not centered
Browse files Browse the repository at this point in the history
DLineEdit是组合控件, DLineEdit和QLineEdit的坐标系不同, 不能直接把QLineEdit的Rect作为绘制区域来使用

Bug: https://pms.uniontech.com/bug-view-277209.html
  • Loading branch information
mhduiy committed Oct 22, 2024
1 parent 659c469 commit 539ff42
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/widgets/dlineeditex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void DLineEditEx::paintEvent(QPaintEvent *event)
pa.setPen(col);
QTextOption option;
option.setAlignment(Qt::AlignCenter);
pa.drawText(lineEdit()->rect(), lineEdit()->placeholderText(), option);
QRect contentRect(lineEdit()->pos(), lineEdit()->size());
pa.drawText(contentRect, lineEdit()->placeholderText(), option);
}
QWidget::paintEvent(event);
}
Expand Down

0 comments on commit 539ff42

Please sign in to comment.