我的ListView這樣的:的Qt/QML如何包裝在文字文本元素whick在列表視圖
Rectangle {
width:(parent.width)
height: (parent.height/3)*2
border.color: "lightsteelblue"
border.width: 2
color:"lightgrey"
radius: 3
ListView {
id:malzemelist
spacing: dp(6)
clip:true
orientation:ListView.Vertical
flickableDirection: Flickable.VerticalFlick
boundsBehavior: Flickable.StopAtBounds
anchors.fill: parent
model:malzememodel
delegate: malzemecomp
focus:true
}
}
我有一個model.I具有填補我的模型,當單擊像 model.append按鈕( {mytext:「blalaladdd」})。我已經設置mytext文本在delage.I工作,但如果我的文本太長,包裝模式不工作。順便說一下,我設置了wrapmode:Text.Wrap.What是問題...
mydelegate代碼:
Component {
id:malzemecomp
RowLayout
{
height: dp(16)
width: parent.width
Text {
id: malzemeresultxt
font.pixelSize: dp(12)
text:malzeme
wrapMode: Text.Wrap
width: parent.width-dp(17)
}
Image {
id: maldeleteimg
height: dp(16)
width: dp(16)
fillMode: Image.PreserveAspectFit
source: "/Images/rejectmalzeme.png"
Layout.alignment: Qt.AlignRight
MouseArea {
anchors.fill: parent
onClicked: {
console.log(malzememodel.count+"/"+index);
TaskResult.taskresult.malzemeler.splice(index,1);
malzememodel.remove(index);
var seri=TaskResult.taskresult.serilaze();
console.log(seri);
}
}
}
}
}
你的委託代碼在哪裏? – Evgeny
好的。我已經編輯了我的帖子。我已經添加了我的代理 –
我認爲問題在於使用'RowLayout'。嘗試將'Layout.maximumWidth'附加屬性添加到'Text'項目。 – Evgeny