Hi, I've been struggling to make a custom class inheriting QAbstractItemModel to be used as model for a listView in my QML HMI. The doc is still very short on the subject. This stuff builds:
void MainWindow::init() {
setupQML ();
// Bind the C++ model instance into the QML context
context->setContextProperty("myModel", static_cast<QObject *>(& model));
}
>From here I'd like to give my model roles for the qml HMI to use. According to
>the doc you're supposed to use roleNames() for this:
Void MyModel::init() {
// Map roles
QHash<int, QByteArray> roleNames;
roleNames.insert(1023, "Icon");
setRoleNames(roleNames);
}
This is where I'm stuck - where do I go from here? How do I make the roles
accessible from qml? I know I'm supposed to implement
QAbstractItemModel::Data() but how is it done?
Regards Mattias
[cid:[email protected]]
Mattias Olausson M.Sc.
Consultant
Automotive Solutions
Lindholmspiren 9 B SE-417 56 Göteborg
Direct / Mobile / SMS / MMS +46 765 487 124
Phone +46 31 744 80 00 Fax +46 31 744 80 01
[email protected]<mailto:[email protected]>
www.cybercomgroup.com<http://www.cybercomgroup.com/>
<<inline: image001.gif>>
_______________________________________________ Qt4-preview-feedback mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback
