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. Scaling TableView
Qt 6.11 is out! See what's new in the release blog

Scaling TableView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 278 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.
  • N Offline
    N Offline
    netpulsar
    wrote on last edited by
    #1

    Hi,
    I have a TableView that is used inside a RowLayout. How do I make the TableView and it's column and row size scale with the size of the Window?

    Here is my code:
    tableViewSpecs.qml

    TableView {
    	anchors.fill: parent
    	clip: true
    	boundsBehavior: Flickable.StopAtBounds
    	id: tableView
    
    	model: TableModel {
    		id: tableModel
    		TableModelColumn {
    			display: "Specification"
    		}
    		TableModelColumn {
    			display: "Description"
    		}
    		TableModelColumn {
    			display: "Limit"
    		}
    	}
    
    	delegate: DelegateChooser {
    		DelegateChoice {
    			column: 0
    			delegate: Rectangle {
    				implicitHeight: 5
    				width: delegateWidth
    				height: delegateHeight
    				border.color: "black"
    				Text {
    					text: display
    				}
    			}
    		}
    		DelegateChoice {
    			column: 1
    			delegate: Rectangle {
    				implicitHeight: 5
    				width: delegateWidth
    				height: delegateHeight
    				border.color: "black"
    				Text {
    					text: display
    				}
    			}
    		}
    		DelegateChoice {
    			column: 2
    			delegate: Rectangle {
    				implicitHeight: 5
    				width: delegateWidth
    				height: delegateHeight
    				border.color: "black"
    				Text {
    					text: display
    				}
    			}
    		}
    	}
    }
    

    part of main.qml

    ColumnLayout {
    anchors.fill: parent

    	RowLayout {
    		Layout.preferredHeight: 250
    		Layout.preferredWidth: 1600
    		Layout.minimumWidth: 900
    		Layout.minimumHeight: 200
    		Layout.fillHeight: true
    		Layout.fillWidth: true
    		Rectangle {
    			Layout.preferredHeight: 250
    			Layout.preferredWidth: 600
    			Layout.fillHeight: true
    			Layout.fillWidth: true
    			Layout.minimumWidth: 500
    
    		TableViewSpecs{
    			id: tableView
    			Layout.topMargin: 30
    			Layout.leftMargin: 30
    			Layout.preferredHeight: 250
    
    			Layout.preferredWidth: 700
    			Layout.minimumWidth: 600
    			Layout.fillHeight: true
    			Layout.fillWidth: true
    			visible: true
    		}
    	}
    
    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