Skip to content

Commit

Permalink
fix: placeholder text horizontalAlignment not work
Browse files Browse the repository at this point in the history
remove loader
  • Loading branch information
kegechen committed Oct 9, 2024
1 parent 2328b7e commit 152852c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions qt6/src/qml/TextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ T.TextField {
verticalAlignment: TextInput.AlignVCenter
onEffectiveHorizontalAlignmentChanged: placeholder.effectiveHorizontalAlignmentChanged()

Loader {
// use loader will cause placeholdertext horizontalAlignment not work
// see QQuickPlaceholderText::updateAlignment()
PlaceholderText {
id: placeholder
active: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
x: control.leftPadding
y: control.topPadding
width: control.width - (control.leftPadding + control.rightPadding)
height: control.height - (control.topPadding + control.bottomPadding)
signal effectiveHorizontalAlignmentChanged

sourceComponent: PlaceholderText {
text: control.placeholderText
font: control.font
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
renderType: control.renderType
}
text: control.placeholderText
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
font: control.font
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
renderType: control.renderType
}

background: EditPanel {
Expand Down

0 comments on commit 152852c

Please sign in to comment.