Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved anchor tableview under column

    QML and Qt Quick
    2
    3
    82
    Loading More Posts
    • 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.
    • S
      sandro4912 last edited by

      I have a Column and a TableView. I want the TableView to be under the Column so I tried this:

      Window {
          id: root
      
      //...
      
          Column{
              id: displayColumn
      
      //...
              }
          }
      
          TableView {
              anchors.top: displayColumn.bottom
              clip: true
      //....
              }
          }
      }
      

      But somehow it does not work. Whats the problem here?

      1 Reply Last reply Reply Quote 0
      • Quang Phu
        Quang Phu last edited by

        @sandro4912
        You have to provide column width and height or implement an item inside column with width and height.
        I tested with code below:

        import QtQuick 2.14
        import QtQuick.Window 2.14
        import QtQuick.Controls 1.4
        
        
        Window {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
            Column {
                id: colum1
        //        width: 30
        //        height: 30
                Rectangle {
                    width: 30
                    height: 30
                    color: "red"
                }
            }
        
            ListModel {
                id: libraryModel
                ListElement {
                    title: "A Masterpiece"
                    author: "Gabriel"
                }
                ListElement {
                    title: "Brilliance"
                    author: "Jens"
                }
                ListElement {
                    title: "Outstanding"
                    author: "Frederik"
                }
            }
            TableView {
                anchors.top: colum1.bottom
                TableViewColumn {
                    role: "title"
                    title: "Title"
                    width: 100
                }
                TableViewColumn {
                    role: "author"
                    title: "Author"
                    width: 200
                }
                model: libraryModel
            }
        }
        
        1 Reply Last reply Reply Quote 1
        • S
          sandro4912 last edited by

          thanks for the effort of reproducing the issue. It solved now.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post