如何使用錨點在 Flickable 中垂直分隔 QML 物件?
代碼片段(在本訊息下方復制)應該顯示由 C 模型提供的文本和影像(C 物件在此片段中被命名為 Global)。
我在線上收到一條錯誤訊息:
anchors { top: _lblMsg1.bottom 8; }
你明白我想要做什么:我希望影像的頂部比它上面的文本底部低 8 個像素。
我收到一條錯誤訊息,但它似乎有效。
你能告訴我,我怎樣才能正確地做到這一點?
<...>
Flickable {
anchors.fill: parent;
Label {
id: _lblMsg1;
text: Global.dataMessages.byId(Global.currService.msg_text1_id);
anchors { top: parent.top; left:parent.left; right: parent.right; }
}
Image {
id: _imgUri1;
cache: false;
source: (Global.currService && Global.currService.img_uri1 ? Global.currService.img_uri1 : "");
asynchronous: true;
anchors { top: _lblMsg1.bottom 8; left:parent.left; right: parent.right;}
horizontalAlignment: Image.AlignHCenter;
fillMode: (Image.width > 400 ? Image.Stretch : Image.Pad);
}
<...>
}
uj5u.com熱心網友回復:
錨只接受其他錨線作為其值。但是,您可以使用邊距來調整錨定,如下所示:
anchors {
top: _lblMsg1.bottom;
topMargin: 8;
left:parent.left;
right: parent.right;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/382088.html
上一篇:QTC 中不完整型別錯誤的分配
