Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QRemoteObject with QDomDocument



  • Hi all,

    Can I use QDomDocument signal/slot in REPC generated replicas ?
    It's question about QtRO

    I have tested QtRemoteObject with simple example, but as soon as I add QDomDocument to .rep file I get error:

    /Qt/5.7/android_armv7/include/QtCore/qmetatype.h: In instantiation of 'constexpr int qMetaTypeId() [with T = QDomDocument]':
    /Qt/5.7/android_armv7/include/QtCore/qmetatype.h:1752:27:   required from 'constexpr int qRegisterMetaType() [with T = QDomDocument]'
    rep_pingpong_replica.h:32:41:   required from here
    /Qt/5.7/android_armv7/include/QtCore/qglobal.h:746:47: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
    

    .rep file

    #include <QDomDocument>
    
    class PingPong {
        SLOT(void ping(QString msg));
        SLOT(void pingXml(QDomDocument xml));
        SIGNAL(pong(QString msg));
    }
    
    

    .rep file will not permit Q_DECLARE_METATYPE
    In my app I'm just using
    qRegisterMetaType<QDomDocument>("QDomDocument");
    for signal/slot, but I don't know how to do it with QtRemoteObject ?

    Best Regards
    Marek



  • Hi

    I have made it to work.
    After rep files are generated with compile error, edit them and paste QDataStream definition before class body. Ifndef is necessary if you have more than one class for remoting with QDomDocument in signal/slot

    #ifndef _xml_operator_
    #define _xml_operator_
    Q_DECLARE_METATYPE(QDomDocument)
    inline QDataStream& operator<<(QDataStream& out, QDomDocument xml)
    {
    out << xml.toString();
    return out;
    }
    inline QDataStream& operator>>(QDataStream& in, QDomDocument& xml)
    {
        QString msg;
        in >> msg;
        xml.setContent(msg);
    return in;
    }
    #endif //_xml_operator_
    

    hope it will help somebody

    Best Regards
    Marek


Log in to reply