这是一个简单的例子:
RowLayout {
spacing: 5
ColumnLayout {
Text {
Layout.fillWidth: true
text: qsTr("Some text")
}
Rectangle {
Layout.fillWidth: true
height: 100
color: "red"
}
}
ColumnLayout {
Text {
Layout.fillWidth: true
text: qsTr("Some more text")
}
Rectangle {
Layout.fillWidth: true
height: 50
color: "red"
}
}
}
这会在width
的{{1}}中生成两个相等的字段,但为什么我必须为所有孩子指定RowLayout
?
以下是从Layout.fillWidth: true
组件中删除Layout.fillWidth: true
的相同示例:
Text
此处RowLayout {
spacing: 5
ColumnLayout {
Text {
text: qsTr("Some text")
}
Rectangle {
Layout.fillWidth: true
height: 100
color: "red"
}
}
ColumnLayout {
Text {
text: qsTr("Some more text")
}
Rectangle {
Layout.fillWidth: true
height: 50
color: "red"
}
}
}
的两个字段在RowLayout
中不相同。
答案 0 :(得分:2)
您可以使用Without using regex, something like this should work for returning the string positions:
<code>
$html = "dddasdfdddasdffff";
$needle = "asdf";
$lastPos = 0;
$positions = array();
while (($lastPos = strpos($html, $needle, $lastPos))!== false) {
$positions[] = $lastPos;
$lastPos = $lastPos + strlen($needle);
}
// Displays 3 and 10
foreach ($positions as $value) {
echo $value ."<br />";
}
</code>
来设置行元素的大小(绝对或相对):
Layout.preferredWidth
答案 1 :(得分:0)
使用带有两列的GridLayout可能更好。
Rectangle {
height: 20
width: 300
color: "green"
GridLayout {
anchors.fill: parent
columns: 2
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
color: "red"
}
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
color: "blue"
}
} //GridLayout
}