helmut1978
helmut1978

Reputation: 437

Qt CheckBox bind to property

I have a class like this

class foo
{
...
QString name
bool  active
...
}

Now I made a UI with the QtDesigner, include a LineEdit and a Checkbox. I use a QStandardItem and a QDataWidgetMapper for the name property, which works fine, but I have no idea how I can bind the checkbox to the active property.

Upvotes: 2

Views: 656

Answers (1)

ahmed
ahmed

Reputation: 5600

Use the Q_PROPERTY in your class so Qt Designer can see those properties
It's easier when you follow Qt coding style, for example use get & set:

class foo
{

    Q_PROPERTY(QString name READ getName)
    Q_PROPERTY(bool active READ isActive)

public:
    QString getName() const;
    bool isActive() const;

private:
    QString m_name
    bool  m_active;
...
}

Upvotes: 4

Related Questions