QML GridLayout text align in column
-
wrote on 28 Nov 2017, 14:24 last edited by
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 -
wrote on 29 Nov 2017, 05:34 last edited by
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; } } }
-
wrote on 29 Nov 2017, 14:14 last edited by
Hello thank you very much but no result... all still to the left..
-
wrote on 29 Nov 2017, 17:43 last edited by
-
wrote on 29 Nov 2017, 17:52 last edited by
I'm working with QT 5.9...
-
wrote on 29 Nov 2017, 17:56 last edited by
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" } }```
-
wrote on 16 Nov 2018, 10:54 last edited by NachoFly
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{}
-
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?
wrote on 10 May 2019, 19:18 last edited byQt version 5.1.1 and the rest of it should be listed. Developing this on Windows 10