Nominate our 2022 Qt Champions!

Custom compound property in QDesigner properties editor

  • Hello

    Is there any way to show compound property of custom widget in QDesigner's property editor?
    For example:

    class MyProp {
        Q_PROPERTY(double a READ a WRITE setA)
        Q_PROPERTY(double b READ b WRITE setB)
        double a() const;
        double b() const;
        void setA(double);
        void setB(double);
        double m_a;
        double m_b;
      class MyWidget: public QWidget {
        Q_PROPERTY(MyProp prop READ prop WRITE setProp)
        MyProp prop() const;
        void setProp(const MyProp&);
        MyProp m_prop;

    I expected it would display as (for example) QSize property.
    But QDesigner does not display prop in properties editor.

    (I've omitted part about qdesigner plugin to make question clearer)

    Thanks in advance

  • Lifetime Qt Champion


    I haven't played with such a construct but I see several problems:

    1. MyProp is a Q_GADGET so it can't have Q_PROPERTY
    2. You didn't declare/register MyProp as a metatype usable by your application.

  • Moderators

    Only a subset of QVariant types are supported by the designer plugins. Scroll down here for a list.

Log in to reply