c++ - How to iterate QVariant? -


i did updated qtcreator 5.5 , created new project, in implementation didn't qlist values in qml (from signal call):

class:

...  int main(int argc, char *argv[]) {      qapplication application(argc, argv);      const qstring mainqmlapp = qstringliteral("qrc:///exemplo.qml");     qquickview view;      qmlregistertype<exemplocontroller>("org.qtproject.example", 1, 0, "exemplocontroller");      view.setsource(qurl(mainqmlapp));     view.setresizemode(qquickview::sizerootobjecttoview);      qobject::connect(view.engine(), signal(quit()), qapp, slot(quit()));     view.setgeometry(qrect(100, 100, 400, 400));     view.show();      return application.exec(); } 

controller:

header file:

... class exemplocontroller : public qwidget {     q_object public:     explicit exemplocontroller(qwidget *parent = 0);     q_invokable void getmatrix();  signals:     void receivematrix(qlist <qlist <double> > matrix);  public slots: }; 

implementation:

... qlist <qlist <double> > net; for(int = 0; < 6; i++){     qlist<double> colormatrix;     colormatrix << 1 << 2 << 1 << 2 << 2 << 2;     net << colormatrix; } emit receivematrix(net); ... 

and.. in qml:

... exemplocontroller {     id: exemplo     onreceivematrix: {          console.log(matrix+" "+matrix.length); //this returns 'qml: qvariant(qlist<qlist<double> >) undefined'     } } ... 

how can these values?

we have qvariantlist , qvariantmap easier iterating values in qml. can attempt use qvariantlist instead of qlist.

qvariantlist , qvariantmap javascript array , object.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -