QML GridLayout text align in column
-
Hello, I'm trying to have my text horizontal align inside the column but nothing work, any one know why?...
The goal is using locale storage database when the data are displayed in the row, all column take the screen width (10 columns) and text is aligned inside the cells.
I don't want use columnSpacing because that cause some trouble when the application is used on other computer with a different resolution...
about text in the column, I try qt.align or anchors.horizontalCenter and many other thing but that is not working, text is always to left of the column.
Could you help me?
Thanks a lot -
Hi!
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") GridLayout { id: grid anchors.fill: parent columns: 3 Text { text: "One"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } Text { text: "Two"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } Text { text: "Three"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } Text { text: "Four"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } Text { text: "Five"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } Text { text: "Six"; Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter; } } }
-
Works for me. What's your Qt version etc?
-
here my code...```
GridLayout {
anchors.fill: parentcolumns: 10 //anchors.left:parent.left Text { id: rimmatriculation text: immatriculation Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: raircrafttype text: aircrafttype Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rnumerodeserie text: numerodeserie Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rdateconstruction text: dateconstruction Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rpremiercertificatimmat text: premiercertificatimmat Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rnumeroLSA text: numeroLSA Layout.alignment: Qt.AlignCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rdateLSA text: dateLSA Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rnumerocertificatnuisance text: numerocertificatnuisance Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.minimumWidth :100 font.pixelSize:22 color: "black" } Text { id: rdateCDN text: dateCDN Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } Text { id: rdatecertificatassurance text: datecertificatassurance Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.minimumWidth :100 font.pixelSize: 22 color: "black" } }```
-
Eventhough the topic is fairly old, it is still unanswered. I was struggling with the same problem and the fix that worked for me was adding
Layout.fillWidth: true
to the
Text{}
-
Works for me. What's your Qt version etc?