ListModel{ id: _model}TableView{ id: _tableView width: 200 anchors.fill: _view anchors.horizontalCenter: _view.horizontalCenter TableViewColumn { role: "image" title: "Title" width: 50 delegate: _delegate } model: _model}Component{ id: _delegate Item { width: 32 height: 32 Image { anchors.horizontalCenter: _tableView.horizontalCenter anchors.verticalCenter: _tableView.verticalCenter width: 32 height: 32 source: "antena" } }}
Item { id: mainItem anchors.fill: parent TableView { id: table anchors.fill: parent TableViewColumn { role: "name" title: "Name" width: table.width/3 delegate: textDelegate } TableViewColumn { role: "level" title: "Level" width: table.width/3 delegate: imageDelegate } TableViewColumn { role: "count" title: "Count" width: table.width/3 delegate: imageDelegate } model: listmodel rowDelegate: _rowDelegate } ListModel { id: listmodel ListElement { name: "avto1"; level: "antena"; count: "sat" } ListElement { name: "avto2"; level: "antena"; count: "sat" } ListElement { name: "avto3"; level: "antena"; count: "sat" } } Component { id: textDelegate Item { Rectangle { anchors.fill: parent color: (styleData.selected)?"skyblue":"white" border.width: 1 border.color: "black" Text { color: (styleData.selected)?"red":"black" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter text: styleData.value } } } } Component { id: imageDelegate Rectangle { border { width: 1; color: "black" } color: (styleData.selected)?"skyblue":"white" Image { width: 32 height: 32 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: styleData.value } } } Component { id: _rowDelegate Item { height: 32 } } }