Custom Widget Class Properties

  • Hello !
    I need some widgets derived from some standard wigets with similar additional functionality (same Properties).
    My first idea was templates, but a QObject template is not possible.
    Now I try to integrate all poperties in a QObject subclass. The custom wiget gets this class property with inclusive its subproberties.
    Is this possible ? Can I get a entry in the property explorer, which shows in expanding mode the subproperties similar to the Font property.
    I tried this, but

        TPropTest itsPropTest;        // a QObject class with properties
        Q_PROPERTY(TPropTest PropTest READ readPropTest)
        TPropTest readPropTest() { return itsPropTest; }

    The problem is that a QObject has no copyconstructor.
    What can I do ????

  • Lifetime Qt Champion


    You have to use a pointer to your QObject if you want to use it like that

  • @SGaist

        TPropTest itsPropTest;
        Q_PROPERTY(TPropTest* PropTest READ readPropTest)
        TPropTest* readPropTest() { return &itsPropTest; }

    This shows no PropTest in the explorer.
    Must I integrate a setter for the whole class ? and how ?

  • Lifetime Qt Champion

    I missed the point about the Property Explorer, I'm really not sure it can handle an embedded object like that.

    The setter follows the same logic as any other property: setReadPropTest(TPropTest *tPropTest);

Log in to reply