• 3998阅读
  • 2回复

QML tableview 数据筛选求助 [复制链接]

上一主题 下一主题
离线黑幕月色
 

只看楼主 倒序阅读 楼主  发表于: 2015-06-21
如何实现Tableview  数据筛选功能, 比如说根据关键字来决定需要显示数据
示例代码如下.
import QtQuick 2.4import QtQuick.Controls 1.3import QtQuick.Window 2.2import QtQuick.Dialogs 1.2
ApplicationWindow {    title: qsTr("Hello World")    width: 640    height: 480    visible: true
    ListModel {        id: libraryModel        ListElement {            title: "A Masterpiece"            author: "OK"        }        ListElement {            title: "Brilliance"            author: "NO"        }        ListElement {            title: "Outstanding"            author: "OK"        }        ListElement {            title: "Otherthings"            author: "NO"        }    }    TableView {        TableViewColumn {            role: "title"            title: "Title"            width: 100        }        TableViewColumn {            role: "author"            title: "Author"            width: 200        }        model: libraryModel    }
    CheckBox {        id: checkBox1        x: 285        y: 55        text: qsTr("Check Box")    }}
离线黑幕月色

只看该作者 1楼 发表于: 2015-06-21
离线彩阳

只看该作者 2楼 发表于: 2015-06-24
SortFilterModel
这个类可以解决你的问题。
上海Qt开发联盟,热忱地欢迎你的加入!
快速回复
限100 字节
 
上一个 下一个