ROW其实相当于我们在C++模式下写的那个水平布局。就是让内部控件一直排列下去。
首先呢,这布局中,先添加的在前,后添加的在后,添加方法很简单,只要这个控件被Row包含就行了。
示例中尝试添加五个按钮,并且这些按钮在同一行
代码如下:
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
Window {
visible: true
width: 300
height: 300
Rectangle{
anchors.fill: parent
Row{
anchors.left: parent.left
anchors.leftMargin: 4
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
Button{
id:button1
text:qsTr("按钮1")
}
Button{
id:button2
text:qsTr("按钮2")
}
Button{
id:button3
text:qsTr("按钮3")
}
Button{
id:button4
text:qsTr("按钮4")
}
Button{
id:button5
text:qsTr("按钮5")
}
}
}
}
效果图很明显: