Hello forum,
I did not get much of a response from my last post. I believe that I did not explain the issue well enough. Let me try again. Consider the following class structures:
class A : public QObject
{
Q_OBJECT
public:
A();
~A();
void initialize();
GLint method1();
private:
GLint var1;
}
Lets describe a bit about the class A. The public method method1() returns the value for var1. The initialize() must be called prior calling method1() so that the member variale value contains the updated value.
Now lets look into another class as follows:
class B : public QQuickItem
{
Q_OBJECT
public:
B();
Q_INVOKABLE float method2();
private:
float var2;
A* a;
};
................
................
B::B()
{
a = new A();
}
float B::method2()
{
return (float)(a->method1());
}
While running the program I found that B::method2() is always returning ZERO, which is incorrect value. The method2 is called from the qml file as follows:
BItem
{
id: bItem
}
Slider {
id: slider1
opacity: 1.0
minimumValue: 1.0
maximumValue: bItem.maxPatchVertices()
stepSize: 1.0
Layout.fillWidth: true
onValueChanged: bItem.outer = value
}
I tried the understand the program flow with the help of the debugger and found that B::method() is called and the value is not updated even after the A::initialize() changes the value. I have seen examples where C++ class member variable is updated from the qml , not vice versa. I believe I am experiencing the latter issue here. As you can see from the qml file, I trying to get the updated value from C++ class member function and set it as a property value fom the slider.
Any idea/refference/example to resolve this ?
Thanks
↧










