Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

Returning a QList to Qml ???

$
0
0
I have a Q_INVOKABLE method that returns a QList<QHash<QString, QString> > when called from Qml, however when I run the code it throws “Error: Unknown method return type: QList<QHash<QString,QString> >”, I’m assuming this is because Qml doesn’t have support for QHash? Because I was able to return a QList<QString> or QStringList. So, how would I do this? The reason I want to do this is I want to pass a struct I created, the best way I’ve found is to convert it to the QList in question, if anyone can think of a better way of passing a whole struct please do tell. The struct is in this format: struct mySubStruct {     char *name;     char *value;     struct mySubStruct *next;     struct mySubStruct *prev; } struct myStruct {     mySubStruct data1;     mySubStruct data2;     mySubStruct data3;     etc.;     etc.; } Now, keep in mind I use this struct all throughout my program, now what I’m doing is just passing the data from the struct to my Qml gui to be displayed, now from Qml I want to be able to access it sort of like this: // This is in a "Component.onCompleted" var data_list = myImportedClass.getDataList(); for(var i = 0; i < data_list.length; i++) {  myModel.append({   item1: data_list[i]["name1"],   item2: data_list[i]["name2"],   etc.,   etc.  }); } or like this: // This is in a "Component.onCompleted" var data_list = myImportedClass.getDataList(); for(var i = 0; i < data_list.length; i++) {  myModel.append({   item1: data_list[i].name1,   item2: data_list[i].name2,   etc.,   etc.  }); } I hope I provided enough info, and thanks in advance for any help.

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>