QML:使用 TextEdit 元素进行简单的自动换行?
我只是 QML 的初学者,我想做一个简单的示例,其中仅包含一个带有 TextEdit 元素的矩形:
import QtQuick 1.0
Rectangle {
width: 400; height: 400
color: "lightblue"
TextEdit {
x: 50; y: 100; width: 300; height: 300
text: "editable text editable text editable text editable text "
font.family: "Helvetica"; font.pixelSize: 32
}
}
这里的想法是只显示几行,用户可以更改或添加。我只是希望它将其显示为多个自动换行的行,而不是仅显示在单行上。我什至不需要滚动条。由于 TextEdit 没有 WrapMode 属性,我该如何执行此操作? :-(
谢谢! 妮娜
I'm just a beginner to QML and I wanted to make a simple example, which contains just one Rectangle with a TextEdit element:
import QtQuick 1.0
Rectangle {
width: 400; height: 400
color: "lightblue"
TextEdit {
x: 50; y: 100; width: 300; height: 300
text: "editable text editable text editable text editable text "
font.family: "Helvetica"; font.pixelSize: 32
}
}
The idea here is to just have a few lines displayed that the user can change or add. I just would like it to display it as multiple word-wrapped lines instead of just on a single line. I don't even need a scrollbar. Since TextEdit does not have a WrapMode property, how can I do this? :-(
Thanks!
Nina
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TextEdit有一个 wordWrap 属性。
请参阅http://doc.qt.nokia.com/4.7/ qml-textedit.html#wrapMode-prop。
如果添加
到 TextEdit 组件,文本将换行为多行。
TextEdit has a wordWrap property.
See http://doc.qt.nokia.com/4.7/qml-textedit.html#wrapMode-prop.
if you add
to the TextEdit component the text is wrapped to multiple lines.