Reputation: 1425
Qt 5.11. I use Column
to position my controls. For this column element I set anchors.leftMargin: 10
. All children items respects this except Grid
.
Screenshot of what I get:
QML code:
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Column
{
anchors.fill: parent
anchors.leftMargin: 10
RadioButton
{
text: qsTr("System proxy")
}
RadioButton
{
text: qsTr("No proxy")
}
RadioButton
{
text: qsTr("Configure manually:")
}
Grid
{
columns: 5
spacing: 10
Label {text: " "}
Label {text: qsTr("Address")}
Label {text: qsTr("Port")}
Label {text: qsTr("Login")}
Label {text: qsTr("Password")}
Label {text: "HTTP"}
TextField {width: 100}
TextField {width: 40}
TextField {width: 100}
TextField {width: 100}
}
}
}
Am I doing something wrong?
Upvotes: 0
Views: 116
Reputation: 243897
The problem is not the Grid but RadioButton
, they have an additional padding:
A Control has the following layout:
So the solution set the leftPadding
to 0 of the RadioButton
s:
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Column
{
anchors.fill: parent
anchors.leftMargin: 10
RadioButton
{
text: qsTr("System proxy")
leftPadding: 0
}
RadioButton
{
text: qsTr("No proxy")
leftPadding: 0
}
RadioButton
{
text: qsTr("Configure manually:")
leftPadding: 0
}
Grid
{
columns: 5
spacing: 10
Label {text: " "}
Label {text: qsTr("Address")}
Label {text: qsTr("Port")}
Label {text: qsTr("Login")}
Label {text: qsTr("Password")}
Label {text: "HTTP"}
TextField {width: 100}
TextField {width: 40}
TextField {width: 100}
TextField {width: 100}
}
}
}
Upvotes: 1