我有一個ListView與他的模型來自U1db.Query讀取和保存操作從/到U1db的作品,但我需要更新ListView模型時,插入一個新的項目數據庫來顯示插入的最後內容(即:我需要執行相同的查詢)。我也試過用ListView和UbuntuListView`,但我無法解決這個問題。當我「拉」列表刷新它,我得到的錯誤:ubuntu qml ListView模型重新加載U1Db查詢
Property 'update' of object U1db::Query(0xe097e0) is not a function
我已經看了看SDK文檔,但我還沒有發現任何有用的例子。感謝您的任何建議!
這裏摘錄(我省略了一些detils):
import QtQuick 2.2
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import Ubuntu.Components.ListItems 1.3 as ListItem //test
import U1db 1.0 as U1db
//the delegate component used by the ListView
Component {
id: peopleListDelegate
Item {
id: personItem
//draw a rectangle aroun the content to display
Rectangle {
//content omitted
}
// This mouse region covers the entire delegate
MouseArea {
//content omitted
}
Row {
id: topLayout
//display some content to be shown inside the Rectangle
}
}
}
//the listView that show the DB Query result
ListView {
id: listView
anchors.fill: parent
model : allPeopleQuery
delegate: peopleListDelegate
highlight: highlightComponent
focus: true
Component{
id: listHeader
Item {
width: parent.width
height: units.gu(10)
Text{
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: i18n.tr("<b> Total people found: </b>") + listView.count
}
}
}
header: listHeader
PullToRefresh {
refreshing: listView.model.status === ListModel.Loading
onRefresh: listView.model.update() // HERE THE PROBLEM, (also using reload() doesn't work)
}
}
U1db.Database {
id: mypeopleDb
.....
}
U1db.Index{
database: mypeopleDb
id: all_field_index
expression: .......
}
U1db.Query {
id: allPeopleQuery
index: all_field_index
query: ["*", "*"]
}