Possibly you have name clashes here. I suggest not to start property and method names from capital letter, this is only for type names (classes). The property (your 1-st case) is the preferred way, as you use it in binding. Also, rename vendorModel property member to m_vendorModel and make it private. One more thing: have you set parent to the object you return in VendorModel() method?
2016-02-12 8:29 GMT+02:00 Willem Ferguson <willemfergu...@zoology.up.ac.za>: > I include an image explaining much of the context of the problem I > encounter. > > I have a QML combobox that needs to respond to a C++ QStringListModel. I do > this as follows: > > At the start where the QML machine is initialised (at the top of the > attached image) > 1) Define and instantiate the underlying C++ class (DownloadManager) as a > global object (downloadhelper), > visible to the C++ code far away. > 2) Define a context pointer to downloadhelper. The handle for this pointer > is "downloadhelper". > > Within the downloadmanager class (the C++ code): > 1) Define a property set (Q_PROPERTY) that allows QML to see several > structures inside the C++ code. > 2) Define the model vendorModel to be used by the QML combobox. The > vendorModel is accessible both > as a QStringListModel (vendorModel) and as a function that returns a > pointer to a QStrinListModel > (VendorModel()). > > In the QML: > 1) The downloadhelper object is seen with the QML code, visible by the > italic font of "downloadhelper" as well > some of the visible parts within downloadhelper, offered in the dropdown > list (right-hand side of attached image) > In fact, the function downloadhelper.fill_computer_list() works as > expected and fills venderModel (the QStringListModel) > with an appropriate QStringList. > > The result: If, within the model specification in the QML: > 1) If I choose "vendorModel" from the dropdown list and execute, there is a > segfault at the model definition in the QML > Commenting out the model definition eliminates the segfault. > 2) If I choose "VendorModel()", the QML processor does not recognise the > identifier > 3) If I choose the source QStringList (not the model based in that > stringlist) I get an error message: > ERROR: Unknown method return type: QStringListModel* > 4) If I choose VendorModel (as defined in the Q_PROPERTY), then I get the > output in the black box at the bottom of the image. > If I take the Q_PROPERTY definition as a yard stick, the READ handle > VendorModel should be the appropriate one. > But VendorModel is not even listed in the dropdown list in the QML code > in the image. > > Any comments or suggestion will be very valuable. > Kind regards, > willem > > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest