Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom Widget Class Properties
Forum Update on Monday, May 27th 2025

Custom Widget Class Properties

Scheduled Pinned Locked Moved General and Desktop
widgets
4 Posts 2 Posters 1.2k Views
  • 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.
  • Andy314A Offline
    Andy314A Offline
    Andy314
    wrote on last edited by Andy314
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Andy314A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

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

        Andy314A Offline
        Andy314A Offline
        Andy314
        wrote on last edited by
        #3

        @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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved