Assuming here's a class named QXXX inherited from QObject, how can i get the address of the property ["Abc"], any idea?
{
Q_OBJECT
Q_PROPERTY(int Val READ Val WRITE setVal)
public:
{
setVal(a);
}
~QABC ()
{
}
QABC (const QABC & rhs)
{
copyFrom(rhs);
}
QABC & copyFrom(const QABC & rhs)
{
if(this == &rhs)
return *this;
setVal(rhs._val);
return *this;
}
QABC & operator = (const QABC & rhs)
{
return copyFrom(rhs);
}
int Val() const { return _val; }
void setVal( int val ) { _val = val; }
private:
int _val;
};
{
Q_OBJECT
Q_PROPERTY(QABC Abc READ Abc WRITE setAbc)
public:
{
setAbc(a);
}
~QXXX()
{
}
QXXX(const QXXX& rhs)
{
copyFrom(rhs);
}
QXXX& copyFrom(const QXXX& rhs)
{
if(this == &rhs)
return *this;
setAbc(rhs._Abc);
return *this;
}
QXXX& operator = (const QXXX& rhs)
{
return copyFrom(rhs);
}
QAbc Abc() const { return _Abc; }
void setAbc( QAbc val ) { _Abc= val; }
private:
QABC _Abc;
};
class QABC : public QObject
{
Q_OBJECT
Q_PROPERTY(int Val READ Val WRITE setVal)
public:
QABC (QObject* parent = 0, int a = 987) : QObject(parent)
{
setVal(a);
}
~QABC ()
{
}
QABC (const QABC & rhs)
{
copyFrom(rhs);
}
QABC & copyFrom(const QABC & rhs)
{
if(this == &rhs)
return *this;
setVal(rhs._val);
return *this;
}
QABC & operator = (const QABC & rhs)
{
return copyFrom(rhs);
}
int Val() const { return _val; }
void setVal( int val ) { _val = val; }
private:
int _val;
};
class QXXX : public QObject
{
Q_OBJECT
Q_PROPERTY(QABC Abc READ Abc WRITE setAbc)
public:
QXXX(QObject* parent = 0, QABC a = QABC()) : QObject(parent)
{
setAbc(a);
}
~QXXX()
{
}
QXXX(const QXXX& rhs)
{
copyFrom(rhs);
}
QXXX& copyFrom(const QXXX& rhs)
{
if(this == &rhs)
return *this;
setAbc(rhs._Abc);
return *this;
}
QXXX& operator = (const QXXX& rhs)
{
return copyFrom(rhs);
}
QAbc Abc() const { return _Abc; }
void setAbc( QAbc val ) { _Abc= val; }
private:
QABC _Abc;
};
To copy to clipboard, switch view to plain text mode
QXXX x;
...
QObject * z = (QObject*)x;
QObject* pointer = z ...?? ???? // to get (&QXXX::_Abc)
I just only know the property name, it's 'Abc', can i get &z->_Abc?
Bookmarks