Set background color on Layout (such as GridLayout)
Solved
QML and Qt Quick
-
I create QT quick component redefinding GridLayout to make simple use.
MyGridLayout.qmlGridLayout { rows:1 columns:0 }
And I use this
myDialog.qmlMyGridLayout { MyGridLayout { Text { } Text { } } MyGridLayout { Button { } } }
It works well to have same setting.
However, I would like to set background color on it. there is no such a property on GridLayout...
Do you know how to do it with my customised component (MyGridLayout)
I would like to do like below.MyGridLayout { color: "white" MyGridLayout { color: "gray" Text { } Text { } } MyGridLayout { color: "black" Button { } } }
-
Not possible. You need to try something like follows. Your grid layout need to child of Rect with appropriate colors.
Rectangle { width: 200;height: 200;color :"black" MyGridLayout { id: grid columns: 3 anchors.fill: parent Text { text: "Three"; font.bold: true; } Text { text: "words"; color: "red" } }
}