我正在使用QT QML开发应用程序.我正面临着QML的一个奇怪问题.我想使用QML划分和显示长文本.我正在使用QT Text元素来执行此任务.我想将此Text放在QT Columnlayout中,并与其他UI元素一起使用.我无法将长文本显示为多行文本.请帮我解决这个问题.这是我的QML代码.
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
color: "#18d28a"
ColumnLayout{
id: base_coloumn_layout
width: parent.width
Layout.margins: 10
Text {
id: application_instruction
width: 640
text: qsTr("xyxvx dgdgdh dhdgdd dhdgdhhgd dhhhdgd dhdgdg dhdgdh djhddh djddgdhgdh dhdgdhgdgh dhgdgdhj dhdgdghdg dhjdgdgd.")
color: "#000000"
font.pointSize: 12
wrapMode: Text.WordWrap
}
}
}
Run Code Online (Sandbox Code Playgroud)
放在外面时,相同的元素正常工作ColoumnLayout.我可以将文本显示为多行,代码如下.我希望相同的代码应该像Child一样工作,ColoumnLayout因为里面会有更多的元素ColoumnLayout
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
color: "#18d28a"
Text {
id: application_instruction
width: 640
text: qsTr("xyxvx dgdgdh dhdgdd dhdgdhhgd dhhhdgd dhdgdg dhdgdh djhddh djddgdhgdh dhdgdhgdgh dhgdgdhj dhdgdghdg dhjdgdgd.")
color: "#000000"
font.pointSize: 12
wrapMode: Text.WordWrap
}
}
Run Code Online (Sandbox Code Playgroud)
ColoumnLayout有什么问题.我错过了要设置的任何属性值.请帮忙
在ColumnLayout内部,将忽略width属性。
而是设置Layout.preferredWidth或Layout.maximumWidth附加Text元素的属性。
如果要使项目填充ColumnLayout的宽度,可以将Layout.fillWidth附加属性设置为true。
| 归档时间: |
|
| 查看次数: |
1164 次 |
| 最近记录: |