Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.8.0
-
None
-
Ubuntu 11.04
Description
When implementing a custom ListModel, on<property name>Changed slots should be provided by the ListModel.
Instead, currently an 'undefined property' is raised when you want to assign a function to that slot.
This is my code:
import QtQuick 1.1 import "lib/json/json2.js" as Json ListModel { id: mongoQuery property MongoCollection collection property variant query property variant sort property int limit: -1 property int skip: 0 property bool snapshot: false property bool $returnKey: false property int $maxScan: -1 property variant $min property variant $max property bool $showDiskLoc: false property variant $hin-t function update() { clear() var cursor = collection.find(query) console.log( Json.JSON.stringify(query) ) if ($returnKey) cursor = cursor._addSpecial("$returnKey", $returnKey) if (snapshot) cursor = cursor.snapshot() if ($min) cursor = cursor._addSpecial("$min", $min) if ($max) cursor = cursor._addSpecial("$max", $max) if ($showDiskLoc) cursor = cursor._addSpecial("$showDiskLoc", true) if ($hint) cursor = cursor._addSpecial("$hint", $hint) if (sort) cursor = cursor.sort(sort) if (skip>-1) cursor = cursor.skip(skip) if (limit>-1) cursor = cursor.limit(limit) while(cursor.hasNext) append(cursor.next()) } onCollectionChanged: collection.refreshed.connect(update) }
And this error is raised:
file:///home/manuel/lib/QtMongo/QtMongo/MongoQuery.qml:50:5: ListModel: undefined property 'onCollectionChanged'
onCollectionChanged: collection.refreshed.connect(update)
EDIT:
oh, I forgot: it works fine using an 'Item' instead of a ListModel. This code does not raise an error:
Item {
property MongoCollection collection
onCollectionChanged: console.log("changed")
}
So mbrasser (qt forums) assumes, that this is a bug in the ListModel parser.