Reputation: 437
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
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