Unsolved Change Property Qml inside Class
-
Hi Guys ,
I want change the property value of a variable in class , But value does not change
Why not change the value ?
tnQ// Class.h QString loginsts; QString getLoginsts() const; void setLoginsts(const QString value); //Class.cpp QString MyClass::getLoginsts() const { return loginsts; } void MyClass::setLoginsts(const QString value) { loginsts = value; } void MyClass::login(QString usr2,QString psw2) { if( ... ) { setLoginsts("true"); } } // button onclicked qml property string loginsts : MyClass.getLoginsts() onClicked: { txt.text = loginsts //There is no value if(loginsts) { .... } }
-
Hi! If you want to use property bindings then you must declare your loginsts with Q_PROPERTY macro. This is well explained here.