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. QObject subclass with properties used as a property in another QObject subclass?

QObject subclass with properties used as a property in another QObject subclass?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    medvedm
    wrote on last edited by
    #1

    Here is what I'm trying to do:

    @
    class Thing1 : QObject
    {
    Q_OBJECT
    QPROPERTY(quint16 someStuff READ getsomeStuff WRITE setsomeStuff)

    public:
    //all the junk you need
    //including constructor, copy constr, destructor

    };

    class Thing2 : public QObject
    {
    Q_OBJECT
    QPROPERTY(Thing1 aThing READ getaThing WRITE setaThing)
    //other properties

    public:
    //all the junk you need.
    };

    Q_DECLARE_METATYPE(Thing1)
    @

    The problem is this: when you implement the setaThing function, you get a compile error because the QObject::operator= is private. So is what I am trying to do completely impossible? I can't have a class with properties as a property for another class with properties?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Yes, it is impossible. QObject cannot be copied, and properties need to be able to be copied. The only thing you could do is to use a pointer to your Thing1 as the property in Thing2.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #3

        why object of QObject or its subclass can't be copy can be found here:

        http://qt-project.org/doc/qt-4.8/object.html#identity-vs-value

        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