Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change Property Qml inside Class
Qt 6.11 is out! See what's new in the release blog

Change Property Qml inside Class

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 642 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MrErfanM Offline
    MrErfanM Offline
    MrErfan
    wrote on last edited by MrErfan
    #1

    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)
                {
    		....
                }
            }
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! If you want to use property bindings then you must declare your loginsts with Q_PROPERTY macro. This is well explained here.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved