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

sending QHostAddress over Qt Dbus



  • I tried to send QHostAddress over Qt Dbus but getting below error.

    /aarch64-buildroot-linux-gnu/sysroot/usr/include/qt5/QtDBus/qdbusmetatype.h:68: error: no match for ‘operator<<’ (operand types are ‘QDBusArgument’ and ‘const QHostAddress’)
    /aarch64-buildroot-linux-gnu/sysroot/usr/include/qt5/QtDBus/qdbusmetatype.h: In instantiation of ‘void qDBusMarshallHelper(QDBusArgument&, const T*) [with T = QHostAddress]’:
    /aarch64-buildroot-linux-gnu/sysroot/usr/include/qt5/QtDBus/qdbusmetatype.h:81:12:   required from ‘int qDBusRegisterMetaType(T*) [with T = QHostAddress]’
    

    but I have provided marshal and unmarshal functions for it.

    QDBusArgument& operator<<(QDBusArgument& argument,
                                          const QHostAddress& ip) {
      argument.beginStructure();
      argument << ip.toString();
      argument.endStructure();
      return argument;
    }
    
    const QDBusArgument& operator>>(const QDBusArgument& argument,
                                                QHostAddress& ip) {
      QString nmosIp;
      argument.beginStructure();
      argument >> nmosIp;
      argument.endStructure();
      ip = QHostAddress{nmosIp};
      return argument;
    }
    

  • Lifetime Qt Champion

    Did you also call qDBusRegisterMetaType<>() - it's needed according to the docs.



  • @Christian-Ehrlicher yes, that's where this error comes, because qDBusRegisterMetaType<>() calls << & >> functions


  • Lifetime Qt Champion

    And are your calls visible to the compiler where you call qDBusRegisterMetaType? Please show the complete code - best in a simple main.cpp


Log in to reply