Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Custom Widget Class Properties

    General and Desktop
    widgets
    2
    4
    996
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Andy314
      Andy314 last edited by Andy314

      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 ????

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Andy314 1 Reply Last reply Reply Quote 0
        • Andy314
          Andy314 @SGaist last edited by

          @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 ?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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);

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post