QT Properties - Syntactic Sugar or Development Tools

I am sure that all of you were at this moment - a definition Q_OBJECTthat carries a ton Q_PROPERTIES, all with fairly trivial accessories:

class ORM_Customer : public QDjangoModel
{
    Q_OBJECT  

    Q_PROPERTY(QString firstname READ firstname WRITE setFirstname)
    Q_PROPERTY(QString lastname  READ lastname  WRITE setLastname)
    Q_PROPERTY(QString phone     READ phone     WRITE setPhone)

    Q_PROPERTY(QString address1  READ address1  WRITE setAddress1)
    Q_PROPERTY(QString address2  READ address2  WRITE setAddress2)
    Q_PROPERTY(QString houseno   READ houseno   WRITE setHouseno)
    Q_PROPERTY(QString postcode  READ postcode  WRITE setPostcode)
[... snip ...]
}

with tons of accessories that look like this:

QString ORM_Customer::firstname() const { return m_firstname; }
QString ORM_Customer::lastname() const  { return m_lastname; }

void ORM_Customer::setFirstname(QString &n) { m_firstname = n; }
void ORM_Customer::setLastname(QString &n)  { m_lastname  = n; }

Given that QDjangoModel uses MetaObject introspection, I cannot rely on dynamic properties here (besides, I like static properties) - the question is, are there any tools that could save me from manual labor?

Qt Creator does not have the ability to simply declare and define some default access devices and their corresponding private variables. Anything else? This probably should have bothered more developers than me.

, , , ?

+5
1

, . , , Qt 5.1, , "moc". . " → moc" Qt 5.1:

Q_PROPERTY: MEMBER , .

+3

All Articles