Inheritance QDataStream



  • I try inheritance QDataStream

    class DPCOQDataStream : public QDataStream
    {
    Q_OBJECT
    public:
        DPCOQDataStream();
        DPCOQDataStream(QIODevice *);
        DPCOQDataStream(QByteArray *, QIODevice::OpenMode flags);
        DPCOQDataStream(const QByteArray &);
    };
    
    DPCOQDataStream::DPCOQDataStream(): QDataStream()
    {
        setByteOrder(QDataStream::LittleEndian);
        setVersion(QDataStream::Qt_5_8);
    }
    
    DPCOQDataStream::DPCOQDataStream(QIODevice *io): QDataStream(io)
    {
        setByteOrder(QDataStream::LittleEndian);
        setVersion(QDataStream::Qt_5_8);
    }
    
    DPCOQDataStream::DPCOQDataStream(QByteArray * io, QIODevice::OpenMode flags): QDataStream(io, flags)
    {
        setByteOrder(QDataStream::LittleEndian);
        setVersion(QDataStream::Qt_5_8);
    }
    
    DPCOQDataStream::DPCOQDataStream(const QByteArray & ba): QDataStream(ba)
    {
        setByteOrder(QDataStream::LittleEndian);
        setVersion(QDataStream::Qt_5_8);
    }
    
    

    but have errors:
    'staticMetaObject': is not a member of 'QDataStream'
    left of '->metaObject' must point to class/struct/union/generic type
    left of '->dynamicMetaObject' must point to class/struct/union/generic type
    'qt_metacast': is not a member of 'QDataStream'
    'qt_metacall': is not a member of 'QDataStream'


  • Qt Champions 2016

    @klynxe said in Inheritance QDataStream:

    I try inheritance QDataStream

    Why??


  • Moderators

    Hi!

    class DPCOQDataStream : public QDataStream
    {
    Q_OBJECT  // <-- bam!
    public:
    

    QDataStream isn't a QObject.



  • @Wieland
    Thank

    @kshegunov
    I use QDataStream in many place and I want default setting to version and byte order


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.