[英]How to render QQuickItem children?
假設我有這個課:
class CustomRow : public QQuickPaintedItem {
Q_OBJECT
CustomRow(QQuickItem* parent) {...}
void paint(QPainter* painter) {
/* Custom painting of children here */
}
}
我如何以舒適的方式放置和繪畫孩子? 舉例來說,如果我有一個percentLeft
財產,我怎么可能讓這個兩個孩子被渲染,使得左占用percentLeft
的空間還有嗎? 假設它在QML中是這樣的:
CustomRow {
percentLeft: 80
Text {
text: "Hi"
}
Text {
text: "Bye"
}
}
我要如何使顯示“ Hi”的文本占據CustomRow
項寬度的80%? 我是否只需要安置孩子並讓他們自己照顧?
我是否只需要安置孩子並讓他們自己照顧?
搞定了。 物品負責自己的繪畫。 您不必為此擔心,僅需與您所做的任何自定義繪畫有關。
您可以使用屬性綁定將子項放置在父項中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.