Skip to content

Commit 7f5bc69

Browse files
committed
fix: center dialog title with vertical offset
1. Replace plain title text with a centered D.Label in DialogTitleBar 2. Align title horizontally centered and vertically offset downward by 30px 3. Constrain title max width to prevent overlapping with side buttons Log: Center the dialog window title with downward offset and width limit fix: 对话框标题居中并添加垂直偏移 1. 将 DialogTitleBar 中的纯文本标题替换为居中的 D.Label 组件 2. 标题水平居中,垂直方向向下偏移 30 像素 3. 限制标题最大宽度,避免与两侧按钮重叠 Log: 将对话框窗口标题居中并设置下移偏移和宽度限制 PMS: BUG-361279
1 parent 5d800eb commit 7f5bc69

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

qt6/src/qml/DialogWindow.qml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,25 @@ Window {
6262
sourceComponent: DialogTitleBar {
6363
enableInWindowBlendBlur: false
6464
icon.name: control.icon
65-
title: control.title
65+
D.Label {
66+
text: control.title
67+
68+
// --- 水平居中 ---
69+
anchors.horizontalCenter: parent.horizontalCenter
70+
71+
// --- 垂直居中并向下偏移 ---
72+
anchors.verticalCenter: parent.verticalCenter
73+
anchors.verticalCenterOffset: 30 // 正数向下移,根据视觉效果调整
74+
75+
// --- 样式设置 ---
76+
font: titleBar.font
77+
palette: titleBar.palette
78+
79+
// 限制最大宽度,避免文字太长冲到左右两边的按钮或图标
80+
width: Math.min(implicitWidth, parent.width - 120)
81+
elide: Text.ElideRight
82+
horizontalAlignment: Text.AlignHCenter
83+
}
6684
}
6785
}
6886

0 commit comments

Comments
 (0)