Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Grid Layout arrangement
Forum Updated to NodeBB v4.3 + New Features

Grid Layout arrangement

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 826 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vijaykarthikeyan
    wrote on last edited by
    #1

    I want to code out a grid layout in QML. After initializing rows and columns count, and elements and when running the project, the grid Layout arrange the elements in center only. I have searched the solution for this where I have found that Grid layout arranges the elements from the center by default and not from 1st row 1st column. How to arrange the elements in QML from the beginning of the layout instead of from center.

    C 1 Reply Last reply
    0
    • V Vijaykarthikeyan

      I want to code out a grid layout in QML. After initializing rows and columns count, and elements and when running the project, the grid Layout arrange the elements in center only. I have searched the solution for this where I have found that Grid layout arranges the elements from the center by default and not from 1st row 1st column. How to arrange the elements in QML from the beginning of the layout instead of from center.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @Vijaykarthikeyan You mean exactly like the example in the GridLayout docs?

      V 1 Reply Last reply
      0
      • C ChrisW67

        @Vijaykarthikeyan You mean exactly like the example in the GridLayout docs?

        V Offline
        V Offline
        Vijaykarthikeyan
        wrote on last edited by
        #3

        @ChrisW67 Yes Sir. Even when I exactly worked out the example which is in that link you posted, it always starting from center. I don't want to arrange my elements in center.
        As I want to create a side panel navigation like display, starting from the middle of the grid layout is not preferable. Also, I don't want to implement other layouts like RowLayout and ColumnLayout

        C V 2 Replies Last reply
        0
        • V Vijaykarthikeyan

          @ChrisW67 Yes Sir. Even when I exactly worked out the example which is in that link you posted, it always starting from center. I don't want to arrange my elements in center.
          As I want to create a side panel navigation like display, starting from the middle of the grid layout is not preferable. Also, I don't want to implement other layouts like RowLayout and ColumnLayout

          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          @Vijaykarthikeyan Show us what you mean by "always starting from center" in a screen shot along with a minimal, compilable example that produces that behaviour.

          1 Reply Last reply
          0
          • V Vijaykarthikeyan

            @ChrisW67 Yes Sir. Even when I exactly worked out the example which is in that link you posted, it always starting from center. I don't want to arrange my elements in center.
            As I want to create a side panel navigation like display, starting from the middle of the grid layout is not preferable. Also, I don't want to implement other layouts like RowLayout and ColumnLayout

            V Offline
            V Offline
            Vijaykarthikeyan
            wrote on last edited by Vijaykarthikeyan
            #5

            @Vijaykarthikeyan I have defined Layout.row and Layout.column. Now it is working but like this now:

            Screenshot 2023-07-26 122955.png

            It is not exactly looking like a table form? Isn't it?

            GridLayout
                                {
                                    id:grid
                                    anchors.fill: parent
                                    rows:60
                                    columns: 3
            
                                    Text { text: "Three";Layout.row: 0;Layout.column: 0; font.bold: true; }
                                    Text { text: "words"; Layout.row: 1;Layout.column: 1;color: "red" }
                                    Text { text: "in";Layout.row: 2; Layout.column: 2;font.underline: true }
                                    Text { text: "a"; Layout.row: 3;Layout.column: 2;font.pixelSize: 20 }
                                    Text { text: "row"; Layout.row: 7;Layout.column: 0;font.strikeout: true }
                                }
            }
            
            V 1 Reply Last reply
            0
            • V Vijaykarthikeyan

              @Vijaykarthikeyan I have defined Layout.row and Layout.column. Now it is working but like this now:

              Screenshot 2023-07-26 122955.png

              It is not exactly looking like a table form? Isn't it?

              GridLayout
                                  {
                                      id:grid
                                      anchors.fill: parent
                                      rows:60
                                      columns: 3
              
                                      Text { text: "Three";Layout.row: 0;Layout.column: 0; font.bold: true; }
                                      Text { text: "words"; Layout.row: 1;Layout.column: 1;color: "red" }
                                      Text { text: "in";Layout.row: 2; Layout.column: 2;font.underline: true }
                                      Text { text: "a"; Layout.row: 3;Layout.column: 2;font.pixelSize: 20 }
                                      Text { text: "row"; Layout.row: 7;Layout.column: 0;font.strikeout: true }
                                  }
              }
              
              V Offline
              V Offline
              Vijaykarthikeyan
              wrote on last edited by
              #6

              @Vijaykarthikeyan Ok,Now I have used Layout.alignment = Qt.Qt.AlignTop for the 1st three elements. It is working. But on using this rule for next row,it fails? why

              V 1 Reply Last reply
              0
              • V Vijaykarthikeyan

                @Vijaykarthikeyan Ok,Now I have used Layout.alignment = Qt.Qt.AlignTop for the 1st three elements. It is working. But on using this rule for next row,it fails? why

                V Offline
                V Offline
                Vijaykarthikeyan
                wrote on last edited by
                #7

                @Vijaykarthikeyan Even I explicitly coded the width of each item, it is not changing still

                GridLayout
                                    {
                                        id:grid
                                        anchors.fill: parent
                                        rows:5
                                        columns: 3
                                        rowSpacing:  0
                                        property int cellWidth: 10
                                        property int cellHeight: 10
                
                                        Text { id:row1;text: "Three";width: grid.cellWidth;height: grid.cellHeight;Layout.row: 0;Layout.column: 0;Layout.alignment: Qt.AlignTop; font.bold: true; }
                                        Text { text: "words";width: grid.cellWidth; height: grid.cellHeight;Layout.row: 0;Layout.column: 1;Layout.alignment: Qt.AlignTop;color: "red" }
                                        Text { text: "in";Layout.row: 0;width:grid.cellWidth; height: grid.cellHeight; Layout.column: 2;Layout.alignment: Qt.AlignTop;font.underline: true }
                                        Text { text: "a";width: grid.cellWidth;height: grid.cellHeight; Layout.row: 1;Layout.column: 0;Layout.alignment: Qt.AlignTop;font.pixelSize: 20 }
                                        Text { text: "row";width:grid.cellWidth; height: grid.cellHeight; Layout.row: 4;Layout.column: 0;font.strikeout: true }
                                    }
                
                1 Reply Last reply
                0
                • V Vijaykarthikeyan has marked this topic as solved on

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved