11-08-2012 05:06 AM
I have a few set of questions
In my application, I have three qml files
1) main.qml - which have a Navigation Page
2) x.qml - which is a Segmented Control having an action item in it. When clicked on the action item displays the third qml file .
3) y.qml - which is a Sheet .In the sheet I have a Text Field .
I have only the originally created cpp files ie. main.cpp , app.cpp , app.hpp
The text field value should be saved into an xml file dynamically.How can I do this?
If in the above mentioned third file ie. y.qml I have given an object name for the text field .Then how can I access the text field from the already existing cpp files ie. main.cpp , app.cpp , app.hpp
Whether I should make another cpp file for accessing the text field using the object name . If yes, how will I connect/access the newly made cpp file with the corresponding qml file( ie. y.qml)
I am really confused with the whole thing and is seriously stuck.
11-08-2012 05:23 AM
First go through following links, it will clear all your doubts..
11-08-2012 05:52 AM
Thank you for the reply
In the first link you provided, gives only the case of the main.qml file and its corresponding class files.
But in my case, I have to get values from the third qml file which donot have its corresponding class files.
How can I get value from the third qml file in app.cpp?
If possible can you provide me some sample code .
11-08-2012 06:20 AM
I got the solution for getting text field value in another cpp file by using context property.
Now how can I save this value along with system date into xml/json file??
11-08-2012 06:33 AM
If you have gone through above links carefully, you would have find, setContextProperty is alrady mentioned there... It will be good if you go thru QT docs..
11-08-2012 06:59 AM
you can find child elements of the root element by using (e.g.)
define the objectName property in your qml element to make it discoverable.
In this case:
11-08-2012 08:40 AM
Dhanya - you keep saying "corresponding cpp file qhwn it comes to qml files". There is no direct association between the file and your "cpp" file. You load your qml tree and make instance of it. then you can search the tree and modify objects within it with "findChild()" function for example.
I think that it would really go a long way if you would take some time to read the documentation. I found people here very helpful and patient, but the solution has to start with your willingness to learn by reading the documentation.
In addition - if you are not proficient in C++ - I would recommend tackling that first - it will really help you down the road.