PDA

View Full Version : How to pass the Java script [var] from qml to .H/.CPP file



Mathan
23rd September 2016, 14:36
Hi,

I had fetched the list of products and stored in javascript var in main.qml. Now I want to pass the var to ListProduct.cpp.
How should I pass the var.

Code Snippets:

main.qml [in button click event]

var varResultArray;

varResultArray = idPortalSearchItems.results[1];

objHomeController.eveWriteXMLFile(varResultArray) //passing var from main.qml

ListProduct.h
----------------
Q_INVOKABLE bool eveWriteXMLFile(var ResultArray);//Showing the error.


Query: What i have to declare in the declaration of the method in LisProduct.h to receive the var as the parameter.


Thanks in advance.

anda_skoa
23rd September 2016, 18:54
Assuming you get the data from C++ in the first place, why not just use the same data type?

Looks a lot like trying to make your life as hard as possible by artifically doing things in JavaScript instead of doing it in C++.

Cheers,
_

Mathan
26th September 2016, 11:43
I want to pass the results which stored in javascript var from the main.qml to the writeXML.cpp.
I can see the count, the searchitems are fetched and want to write in XML format.

How can I achieve this.

Code snippet:

var varResultArray;

varResultArray = idPortalSearchItems.results[1];

Query:

How Can I pass it by Javascript var Ex:
objHomeController.eveWriteXMLFile(varResultArray ); //Passing an Js variable


writeXML.h
------------

What will be the datatype of the argument of the method?
Ex:
Q_INVOKABLE bool eveWriteXMLFile(??????? varResultArray ); //What will be the datatype?




Thanks In advance.