swa*_*ggg 1 qt kde widget plasmoid qml
我无法弄清楚这一点。我的意思是 Qml 文本项中文本行之间的垂直间距。我不能使用富文本,而且 GridLayout 似乎破坏了我的环绕、水平对齐和检查截断的能力。这是在一个矩形内。
Text{
width:10
wrapMode: Text.Text.Wrap
text:"This will be broken into multiple lines. How could I set the vertical spacing between them?"
}
Run Code Online (Sandbox Code Playgroud)
我的意思是:
对比
一个好习惯是检查文档。浏览它,您可以看到一个名为 的属性lineHeight。我相信这就是你要找的。从文档:
lineHeight : real设置文本的行高。该值可以以像素或乘数为单位,具体取决于
lineHeightMode。
他们还告诉你如何使用它
默认值为 1.0 的乘数。行高必须是正值。
使用lineHeight作为乘数,您可以模仿下面的行间距枚举中的MSWord。
Single
1.5 lines
Double
Multiple
Run Code Online (Sandbox Code Playgroud)
下面是一个例子:
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
visible: true
width: 200
height: 300
Text {
id: text
width: 175
anchors.centerIn: parent
// text: "HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO"
text: "Cat ipsum dolor sit amet, sleep nap. You call this cat food. Push your water glass on the floor."
font.family: "Monaco" // Monaco ??
wrapMode: Text.WordWrap // Make the text multi-line
horizontalAlignment: Text.AlignHCenter
// lineHeight: 1.0 // single-spacing (default)
lineHeight: 1.5 // 1.5 line-spacing
// lineHeight: 2.0 // double-spacing
// lineHeight: 3.0 // triple-spacing
}
}
Run Code Online (Sandbox Code Playgroud)
以下是使用不同值的结果lineHeight(在典型的 MacOS 上)
单行距
1.5 倍、双倍 (2x)、三倍 (3x)
但是,如果您想模仿其他行间距枚举:
At least
Exactly
Run Code Online (Sandbox Code Playgroud)
您需要修改像素高度。您可以通过设置lineHeightMode为来做到这一点Text.FixedHeight。像这样
Window {
visible: true
width: 200
height: 300
Text {
id: text
width: 175
anchors.centerIn: parent
text: "Cat ipsum dolor sit amet, sleep nap. You call this cat food. Push your water glass on the floor."
font.family: "Monaco" // Monaco ??
wrapMode: Text.WordWrap // Make the text multi-line
lineHeightMode: Text.FixedHeight
lineHeight: 6 // exaggerated, text will be scrunched up
}
}
Run Code Online (Sandbox Code Playgroud)
正好 6
| 归档时间: |
|
| 查看次数: |
4313 次 |
| 最近记录: |