string formatting custom object in grantlee

Daniel Poelzleithner poelzi at poelzi.org
Mon Jan 18 23:52:50 GMT 2021


Hi,

I just added grantlee to the mixxx dj software for file formatting and
maybe some other features soon and have to say: grantlee is really nice.

I have a custom Q_GADGET class I can use successfully as a property type:

class Keys final {
  Q_GADGET
  public:
    Q_PROPERTY(QString traditional READ getTraditional)
    Q_PROPERTY(QString openkey READ getOpenkey)
    Q_PROPERTY(QString lancelot READ getLancelot)
    Q_PROPERTY(bool isValid READ isValid)

...

    QString getTraditional() const;
    QString getOpenkey() const;
    QString getLancelot() const;
};

Q_DECLARE_METATYPE(Keys)


I this works nicely if I write "{{ track.key.traditional }}", but I
would also like that {{ track.key }} becomes a valid string.

Is this even possible ?

kind regards
 poelzi


More information about the kde-pim mailing list