为了账号安全,请及时绑定邮箱和手机立即绑定

如何隐藏 QML 中 TableView 中未使用的行?

如何隐藏 QML 中 TableView 中未使用的行?

蓝山帝景 2023-09-21 16:55:26
下面的代码显示了表中未使用的行。我希望未使用的行消失。应显示空白。import QtQuick 2.12import QtQuick.Window 2.12import QtQuick.Controls 1.4Window {    visible: true    width: 640    height: 480    TableView    {        height: 300; width: 300        TableViewColumn {                role: "title"                title: "Title"                width: 100            }            TableViewColumn {                role: "author"                title: "Author"                width: 200            }            model: libraryModel    }    ListModel {        id: libraryModel        ListElement {            title: "A Masterpiece"            author: "Gabriel"        }        ListElement {            title: "Brilliance"            author: "Jens"        }        ListElement {            title: "Outstanding"            author: "Frederik"        }    }}我有什么选择?
查看完整描述

1 回答

?
蝴蝶刀刀

TA贡献1801条经验 获得超8个赞

必须在rowDelegateTableView 中添加以下行:

readonly property int modelRow: styleData.row ? styleData.row : 0

        rowDelegate: Rectangle 
                     {
                                             id: rowDel
                        border.width: 1
                        height:  52
                        width: 2000

                        readonly property int modelRow: styleData.row ? styleData.row : 0
                     }


查看完整回答
反对 回复 2023-09-21
  • 1 回答
  • 0 关注
  • 92 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信