Den 20-04-2012 00:53, Artem Marchenko skrev: > Hi All > > I've go a model coming from C++ (Inhertited from QAbstractListItemModel) > that is basically a list of contact for an instant messenger. > > App's UI, however, is to include one more special contact representing > the current user (it makes sense on our devices with extremely > discouraged chrome elements such as extra headers, scrollbars, etc). > > I can certainly, modify the model on C++ side, yet.. this special item > is really just about the UI representation and therefore it seems very > logical to me to perform such a modification in QML side. Is there a way > to somehow inject an item into a model coming from C++? Or maybe there > is a way to apply some rules to C++ model and make a QML ListModel or > something like that as a result?
Yes, you can do this in QML, coupled with some Javascript and signal handlers. But why on earth would you want to, when it's so much easier to have it in the model? If you want to, you can add a bool flag on each item that says if it's your special item or not. Let it sit in the model, it's *by far* the easiest for you. If you are worried about tainting your model with something that doesn't match the concept it models, then you're on the wrong track. Your UI obviously mixes concepts in the same area, which is why you have a problem with the low-end model code. Fix your UI to not show a special item that is a different concept, or accept that you should add it to the model. I would choose one of those two options, because the others are worse. Bo Thorsen, Fionia Software. -- Expert Qt and C++ developer for hire Contact me if you need expert Qt help http://www.fioniasoftware.dk _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml