查看完整版本: [-- QML tableview  column header可以合并吗 --]

QTCN开发网 -> Qt QML开发 -> QML tableview  column header可以合并吗 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

oracle513 2016-08-11 16:32

QML tableview  column header可以合并吗

[attachment=15611]

领导要这样的tableview 求助各位怎么实现 我刚用qml不久 不熟悉 谢谢

never_forget 2016-08-12 08:36
        TableView {
            id: tableView
            width: parent.width
            anchors.top: parent.top
            anchors.bottom: rectButtons.top
            anchors.bottomMargin: mm * 2
            clip: true
            TableViewColumn {
                width: parent.width / 3
                role: "company"
                title: "供电单位"
                resizable: false
            }
            TableViewColumn {
                width: parent.width / 3
                role: "stationNumber"
                title: "台区编号"
                resizable: false
            }
            TableViewColumn {
                width: parent.width / 3
                role: "stationName"
                title: "台区名称"
                resizable: false
            }
            itemDelegate: Rectangle {
                width: tableView.width / 3
                height: mm * 10
                color: tableView.currentRow === styleData.row ? "#555555" : "lightgray"
                Text {
                    id: contentText
                    text: styleData.value
                    width: parent.width
                    height: parent.height
                    font.pixelSize: 2.5 * mm
                    elide: Text.ElideRight
                }
                MouseArea {
                    anchors.fill: parent
                    onPressed: {
                        tableView.currentRow = styleData.row;
                    }
                    onClicked: {
                        //选中的值
                        currentCompany = libraryModel.get(styleData.row).company;
                        currentStationNumber = libraryModel.get(styleData.row).stationNumber;
                        currentStationName = libraryModel.get(styleData.row).stationName;
                    }
                }
            }

            headerDelegate: Rectangle {
                width: tableView.width / 3
                height: mm * 10
                color: "#f0f0f0"
                Text {
                    id: headText
                    text: styleData.value
                    width: parent.width
                    height: parent.height
                    font.pixelSize: 3 * mm
                    verticalAlignment: Text.AlignVCenter
                    elide: Text.ElideRight
                }
            }
            rowDelegate: Rectangle {
                width: meterList.width / 3
                height: 10 * mm
                color: "#f4f4f4"
            }

            model: libraryModel
        }


never_forget 2016-08-12 08:37
item 的delegate 估计要变一下,楼主加油。。。

oracle513 2016-08-12 13:54
never_forget:item 的delegate 估计要变一下,楼主加油。。。 (2016-08-12 08:37) 

Thx


查看完整版本: [-- QML tableview  column header可以合并吗 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled