Qt-interest Archive, February 2007
'staticMetaObject' : is not a member of 'QDomDocument' ?
Message 1 in thread
Hi,
This subclassing is fine:
class DomDoc : public QDomDocument
{
public:
DomDoc(){};
};
I try to use signal-slot in the subclass, so I add Q_OBJECT first.
class DomDoc : public QDomDocument
{
Q_OBJECT // ???
public:
DomDoc(){};
};
I got moc error:
error C2039: 'staticMetaObject' : is not a member of 'QDomDocument'
This ties my hands!
Why NOT allow to use signal-slot in QDomDocument's subclasses?
Thanks,
Lingfa
--
[ signature omitted ]
Message 2 in thread
A QDomDocument is a QDomNode, which is not a QObject, therefore cannot
use the signal/slot mechanism.
QDomNode implemented value semantics, which would interfere with the
signal/slot mechanism. If you only want signals on your DomDoc class you
might like to do this:
class DomDoc : public QObject
{
Q_OBJECT
public:
...
signals:
...
private:
QDomDocument m_doc;
};
But then you will not be able to pass you DomDoc instances around as
values, they will have to be either short lived, globally declared, or
created on the heap.
lingfa Yang wrote:
> Hi,
>
> This subclassing is fine:
>
> class DomDoc : public QDomDocument
> {
> public:
> DomDoc(){};
> };
>
> I try to use signal-slot in the subclass, so I add Q_OBJECT first.
>
> class DomDoc : public QDomDocument
> {
> Q_OBJECT // ???
> public:
> DomDoc(){};
> };
>
> I got moc error:
>
> error C2039: 'staticMetaObject' : is not a member of 'QDomDocument'
>
> This ties my hands!
> Why NOT allow to use signal-slot in QDomDocument's subclasses?
>
> Thanks,
> Lingfa
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 3 in thread
Thanks, Andrew and Anderson,
I will switch the subclassing into composition of QDomDocument as you
suggested.
Lingfa
--
[ signature omitted ]
Message 4 in thread
Because QDomDocument doesn't inherit QObject.
> Hi,
>
> This subclassing is fine:
>
> class DomDoc : public QDomDocument
> {
> public:
> DomDoc(){};
> };
>
> I try to use signal-slot in the subclass, so I add Q_OBJECT first.
>
> class DomDoc : public QDomDocument
> {
> Q_OBJECT // ???
> public:
> DomDoc(){};
> };
>
> I got moc error:
>
> error C2039: 'staticMetaObject' : is not a member of 'QDomDocument'
>
> This ties my hands!
> Why NOT allow to use signal-slot in QDomDocument's subclasses?
>
> Thanks,
> Lingfa
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]