Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TableView row height
Forum Update on Monday, May 27th 2025

TableView row height

Scheduled Pinned Locked Moved QML and Qt Quick
tableviewheightrowdelegate
15 Posts 4 Posters 7.4k 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.
  • M Offline
    M Offline
    morte
    wrote on last edited by morte
    #3

    @sierdzio said:

    Does rowDelegate.height work for you? Or just chekcing the delegate you have connected?

    No, i dont know how to access height property of rowDelegate.
    I want get row height value to set same height in my custom section delegate.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      th.thielemann
      wrote on last edited by
      #4

      But this sets the height for all rows:

          TableView
          {
              id: tableView
              anchors.fill: tableArea
              headerDelegate: headersDel
              rowDelegate:
              Rectangle
              {
                  height: 30 // Height for all columns
              }
      

      ...
      }

      and in your column delegate you can use:

          Component
          {
              id: iconRowDelegate
              Image
              {
                  anchors.fill: parent            
                  fillMode: Image.Pad
                  source: "Icon.png"
              }
          }
      
      M 1 Reply Last reply
      0
      • T th.thielemann

        But this sets the height for all rows:

            TableView
            {
                id: tableView
                anchors.fill: tableArea
                headerDelegate: headersDel
                rowDelegate:
                Rectangle
                {
                    height: 30 // Height for all columns
                }
        

        ...
        }

        and in your column delegate you can use:

            Component
            {
                id: iconRowDelegate
                Image
                {
                    anchors.fill: parent            
                    fillMode: Image.Pad
                    source: "Icon.png"
                }
            }
        
        M Offline
        M Offline
        morte
        wrote on last edited by
        #5

        @th.thielemann
        I don't want to redefine rowDelegate, i want get height from it (since it differs depending on platform and pixel density).
        Question become: how to access rowDelegate's height property?

        p3c0P 1 Reply Last reply
        0
        • M morte

          @th.thielemann
          I don't want to redefine rowDelegate, i want get height from it (since it differs depending on platform and pixel density).
          Question become: how to access rowDelegate's height property?

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #6

          @morte Since there is no other way, for now, you can use private properties.

          console.log(tableview.__currentRowItem.height) 
          //tableview = id of TableView
          

          157

          1 Reply Last reply
          1
          • M Offline
            M Offline
            morte
            wrote on last edited by morte
            #7

            @p3c0
            I get actual height value, but first row in view not draws after that, i don't know why yet.

            TableView {
            	id: view
            	property int row_height
                anchors.fill: parent
            	section.delegate: section_delegate
                 Component.onCompleted {
                    currentRow = 0;
                    row_height = ____currentRowItem.height;
                 }
            }
            
            Component {
            	id: section_delegate
            	Rectangle {
            		width: view.width
            		height: view.row_height
            	}
            }
            
            p3c0P 1 Reply Last reply
            0
            • M morte

              @p3c0
              I get actual height value, but first row in view not draws after that, i don't know why yet.

              TableView {
              	id: view
              	property int row_height
                  anchors.fill: parent
              	section.delegate: section_delegate
                   Component.onCompleted {
                      currentRow = 0;
                      row_height = ____currentRowItem.height;
                   }
              }
              
              Component {
              	id: section_delegate
              	Rectangle {
              		width: view.width
              		height: view.row_height
              	}
              }
              
              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #8

              @morte Can you explain with an example what you are trying to do ?

              157

              M 1 Reply Last reply
              0
              • p3c0P p3c0

                @morte Can you explain with an example what you are trying to do ?

                M Offline
                M Offline
                morte
                wrote on last edited by
                #9

                @p3c0
                There is TableView with my section delegate and i want to set section delegate's height same as height of rows in view.

                p3c0P 1 Reply Last reply
                0
                • M morte

                  @p3c0
                  There is TableView with my section delegate and i want to set section delegate's height same as height of rows in view.

                  p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #10

                  @morte You will need to set current item in TableView. You can do this by using currentRow of TableView.

                  Component.onCompleted: tableView.currentRow = 0
                  

                  157

                  M 2 Replies Last reply
                  0
                  • p3c0P p3c0

                    @morte You will need to set current item in TableView. You can do this by using currentRow of TableView.

                    Component.onCompleted: tableView.currentRow = 0
                    
                    M Offline
                    M Offline
                    morte
                    wrote on last edited by
                    #11

                    @p3c0
                    Thats it, thanks!

                    1 Reply Last reply
                    0
                    • p3c0P p3c0

                      @morte You will need to set current item in TableView. You can do this by using currentRow of TableView.

                      Component.onCompleted: tableView.currentRow = 0
                      
                      M Offline
                      M Offline
                      morte
                      wrote on last edited by morte
                      #12

                      @p3c0
                      I have just tested it: anyway setting
                      Component.onCompleted: tableView.currentRow = 0
                      in view gives incorrect behavior of view

                      p3c0P 1 Reply Last reply
                      0
                      • M morte

                        @p3c0
                        I have just tested it: anyway setting
                        Component.onCompleted: tableView.currentRow = 0
                        in view gives incorrect behavior of view

                        p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #13

                        @morte Do you get the height properly after setting currentRow ?

                        157

                        M 1 Reply Last reply
                        0
                        • p3c0P p3c0

                          @morte Do you get the height properly after setting currentRow ?

                          M Offline
                          M Offline
                          morte
                          wrote on last edited by morte
                          #14

                          @p3c0
                          I get actual height value, but first row in view not draws after that, i don't know why yet.

                          TableView {
                          	id: view
                          	property int row_height
                              anchors.fill: parent
                          	section.delegate: section_delegate
                               Component.onCompleted {
                                  currentRow = 0;
                                  row_height = __currentRowItem.height;
                               }
                          }
                          
                          Component {
                          	id: section_delegate
                          	Rectangle {
                          		width: view.width
                          		height: view.row_height
                          	}
                          }
                          
                          p3c0P 1 Reply Last reply
                          0
                          • M morte

                            @p3c0
                            I get actual height value, but first row in view not draws after that, i don't know why yet.

                            TableView {
                            	id: view
                            	property int row_height
                                anchors.fill: parent
                            	section.delegate: section_delegate
                                 Component.onCompleted {
                                    currentRow = 0;
                                    row_height = __currentRowItem.height;
                                 }
                            }
                            
                            Component {
                            	id: section_delegate
                            	Rectangle {
                            		width: view.width
                            		height: view.row_height
                            	}
                            }
                            
                            p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #15

                            @morte What do you mean by not draws ? See if you get updated height inside the Component.

                            157

                            1 Reply Last reply
                            0

                            • Login

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