[SailfishDevel] Problem with QQmlListProperty
Markus Svensson
markus.svensson at me.com
Sun Dec 29 20:50:25 UTC 2013
Hi guys,
I'm trying to expose my database layer to QML via a QQmlListProperty - however I'm running into problems... I've probably set it up wrong - but I can't figure out where. My C++ skills are a bit rusty after years and years of Java work... :)
This is my setup code:
QQmlListProperty<Note> NoteList::notes() {
return QQmlListProperty<Note>(this, &_notes, &append,
&size,
&at,
&clear);
}
These are the actual methods I'm trying to pass in to the list property:
static void append(QQmlListProperty<Note> *property, Note* value) {
NoteList *list = (NoteList*) property;
list->addNote(value);
}
static void clear(QQmlListProperty<Note> *property) {
NoteList *list = (NoteList*) property;
list->clearNotes();
}
static int size(QQmlListProperty<Note> *property) {
NoteList *list = (NoteList*) property;
return list->countNotes();
}
static Note* at(QQmlListProperty<Note> *property, int index) {
NoteList *list = (NoteList*) property;
return list->noteAt(index);
}
When I compile - I get this:
/Users/markus/Documents/SailfishOS/build-SilicaNote-MerSDK_SailfishOS_i486_x86-Debug/notelist.o:-1: In function `QQmlListProperty'
/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::append(QQmlListProperty<Note>*, Note*)
File not found: /usr/include/qt5/QtQml/qqmllist.h
/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::at(QQmlListProperty<Note>*, int)'
File not found: /usr/include/qt5/QtQml/qqmllist.h
/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::clear(QQmlListProperty<Note>*)'
File not found: /usr/include/qt5/QtQml/qqmllist.h
:-1: error: collect2: ld returned 1 exit status
Does anyone have any idea what I'm doing wrong?
The broken code is in a separate branch on GitHub - https://github.com/Ortofta/SilicaNote/tree/borked - feel free to look around.
It is a WIP and learning experience - so don't expect greatness.
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131229/4377b85e/attachment.html>
More information about the Devel
mailing list