我有2x2 Gridlayout。所有项目都左对齐,每列占据空间的50%。
现在我想将GridLayout 20像素中的4个项目之一移到右侧。我怎么做?
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
Gridlayout {
rows: 2
flow: GridLayout.TopToBottom
TextEdit {
Layout.alignment: Qt.AlignLeft
text: "test 1"
}
Image {
// This one is supposed to be aligned left + 20 pixels
source: "cool-pic.jpg"
}
TextEdit {
Layout.alignment: Qt.AlignLeft
text: "test 3"
}
TextEdit {
text: "test 4"
}
}
答案 0 :(得分:1)
我找到了这个解决方案。它有效,也许对你有用。您可以根据需要更改宽度
import QtQuick 2.2
import QtQuick.Layouts 1.1
GridLayout {
rows: 2
flow: GridLayout.TopToBottom
TextEdit {
Layout.alignment: Qt.AlignLeft
text: "test 1"
}
Row{
Rectangle{width: 20;height:parent.height; color:"transparent"}
Image {
// This one is supposed to be aligned left + 20 pixels
source: "sub/tst.jpg"
}
}
TextEdit {
Layout.alignment: Qt.AlignLeft
text: "test 3"
}
TextEdit {
text: "test 4"
}
}