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. anchor tableview under column

anchor tableview under column

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 319 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.
  • S Offline
    S Offline
    sandro4912
    wrote on last edited by
    #1

    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
    0
    • Quang PhuQ Offline
      Quang PhuQ Offline
      Quang Phu
      wrote on last edited by
      #2

      @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
      1
      • S Offline
        S Offline
        sandro4912
        wrote on last edited by
        #3

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

        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