I am doing the NFC project. In this I need to detect the tag and read the tag contents from the NFC tag and i need to send the tag id to the PHP server. From the server side i will get the response as {tagId&tagcontent}. After this i need to extract the tagId and tagcontents. Till this i have finished and working fine. Now my problem is to pass the value to another class. As soon as i get the SUCCESS response from server i need to pass the extracted values to another class. How can i do that. I am new to Qt programming. Please help me.
Share
You can pass the parameters as key value pairs i.e. use a QHash or a QVector for this purpose.
Moreover, if you want the information ot be too specific, you can define a custom C++ class, containing values for the response fields and pass the reference from your 1st class to the other class.
Parameter passing in Qt is similar to C++.
Your QStringList, QVector or QHash all are just classes.
You can pass objects of these class as any other custom class.
For example:
In your target class (say T):
In your calling class(say C):
More specifically, you can pass parameters inC++ either by value or by reference.
For passing objects, it is better to pass them via reference.
Passing by value means that a copy of the object is made on the callee’s stack and altering the object means altering a local copy so the caller’s object is unchanged when the function returns. Passing by reference means that the address of the object is send (a reference holds an address but behaves like an object) so that the callee can directly alter the original object.
Have a look at this thread for What's the difference between passing by reference vs. passing by value?
A nice explanation with examples is provided on codeforum at http://www.codeguru.com/forum/showthread.php?t=343473