11-03-2012 12:35 PM
Can't find any info on how to resolve this issue.
In C++ I can define a QString and in QML I can define a string. And, I want to communicate between QML and C++ using javascript functions.
Why examples use hardcoded values I don't know. That is not the real world, values are read from files, databases and user input so that is how examples should be written. If they were I wouldn't be asking this question.
My communication (QML<-->c++) is not working and because I can't find any documentation that clearly says what the relationship is between a string and a QString, what includes or imports are required to use in appropriate, whether javascript recognizes a QString, string etc I don't know if incompatability is the issue.
I can define a "string" property but not a "QString" property for a QML control.
Can anyone clarify the relationship or point to documentation or to an example that shows an interchange of data between QML and C++ method with QString arguments/parameters.
11-03-2012 03:17 PM
11-03-2012 06:38 PM
I've already read the integration document and based by objects on it.
No where have I found any statement that says QStrings are only used in C++ and sometimes but not always handles the communication between them and strings. When a lot of things aren't working one does need to check and get answers to potential problems and how strings are handled in any language especially C are problematic for all programmers.
I managed to get a breakpoint on a method/function that showed the string was passsed to QString ok. Haven't done the reverse yet but not an issue yet.
So what is not working is methods are not recognized. No compile errors, no execution error messages, method is not entered, breakpoint is not reached.
Now, tried with two classes. Same issue one method is executed as expected, another is not. Does not matter whether Q_INVOKABLE is specified for either one that executes/doesn't execute. In other words method A executes always, method B never does.
I made Method B a WRITE for a Q_PROPERTY and it worked. Method A is a strait method call an it works.
So I don't have a clue why a method that looks and is defined like any other method is not invoked.
11-04-2012 02:00 AM
as Peter wrote: posting some code would help
I'm doing communication between C++ and QML in both directions and it works.
there are so many examples out there from Cascades site and you should also go through the examples from Cascades-Samples and Cascades-Community-Samples on github
this will cost some time - but it's worth
it's a new platform and it's a beta - and for this - from my POV - the documentation and samples together with all the help from this forum and on Twitter RIM does a good job to help devs to start with Cascades
01-14-2013 02:30 AM
hello.. did you solve the problem? I mean the qstring and string communication between c++and qml, I also encounter the problem, and i search find the Qstring has a toSTDstring() function to do that.. but i did not success on that.. could u tell me how you solve that? thanks
01-14-2013 04:06 AM
what exactly is your problem ?
without describing your usecase and some code it's difficult to guess
01-14-2013 06:43 AM
well, actually my problem is solved, previously I wanna assign some QString value achieved from database to one string property in qml, which this process seems got some error.. that's why I asked how to communication from Qstring from C++ with string from QML..
code may like :
in xxx.qml
property string id
......
ListView{
......
onTrigered{
var selectedItem = dataModel.data(indexPath);
id=selectedItem.customerID;
}// customerID is Qstring and id is string, so this could not work, and the problem is how make it work.
01-14-2013 07:39 AM