Passing the object from QML to CPP file?
Hi,
I am developing an app.
Query:
How to pass the object from QML to CPP file, what will be object type in QT?
Code:
Login.QML
Code:
function metPassObject()
{
var myCar = new Object();
myCar.make = "Ford";
myCar.model = "Mustang"
myCar.year = 1969;
objQtCPPSearchVOne.metPassObject(myCar);
}
.H file:
Code:
Q_INVOKABLE void metPassObject (type parameter)- what will be the parameter type?
.CPP file:
Code:
void metPassObject(type parameter)
{
//How to access the object?
}
Thanks is Advance.
Re: Passing the object from QML to CPP file?
My guess would be QJSValue
Code:
void metPassObject(const QJSValue &value)
{
QString make
= value.
property("make");
}
But there could be other ways of achieving your actual goal.
E.g. is this function intended to be called with different objects from different parts of the QML?
Cheers,
_