qdbusxml2cpp未知类型

 llllllw_wlllllll 发布于 2023-01-19 13:46

使用qdbusxml2cpp程序将以下xml转换为Qt类时,我收到此错误:

qdbusxml2cpp -c ObjectManager -a ObjectManager:ObjectManager.cpp xml/object_manager.xml 
Got unknown type `a{oa{sa{sv}}}'
You should add  to the XML description

D-Feet描述:

在此输入图像描述

XML:











从这个网站(http://techbase.kde.org/Development/Tutorials/D-Bus/CustomTypes)我明白我需要在XML中添加一个注释才能使工具正常工作.

这是我到目前为止:

a{oa{sa{sv}}}

https://alteeve.ca/w/List_of_DBus_data_types
o == A UTF-8 string whose value is a valid DBus object path.

array { object_path array { string array { string variant } } }


QVariantMap in the arguments (type "a{sv}")
QMap

但是,我不确定{oa {sa {sv}}}的注释应该是什么,有人可以帮助我理解吗?谢谢!

1 个回答
  • openSUSE imagewriter是一个GPL许可项目,其中包含如何执行此操作的示例.
    (相关文件:udisks2_interface.*)


    a{sv}是一个字符串:变体对的字典.
    QVariantMap适合这个签名.

    a{sa{sv}}是字符串的字典:a{sv}对.
    QMap<QString, QVariantMap>适合这个签名.

    a{oa{sa{sv}}}是objectpath的一个词:a{sa{sv}}对.
    QMap<QDBusObjectPath, QMap<QString, QVariantMap>>适合这个签名.

    我们应该在头文件中隐藏一些typedef后面的尖括号:

    typedef QMap<QString, QVariantMap> InterfaceList;
    typedef QMap<QDBusObjectPath, InterfaceList> ManagedObjectList;
    

    然后在同一个头文件中声明他们的QMetaTypes:

    Q_DECLARE_METATYPE(InterfaceList)
    Q_DECLARE_METATYPE(ManagedObjectList)
    

    然后在运行时使用Qt元类型系统注册它们:

    qDBusRegisterMetaType<InterfaceList>();
    qDBusRegisterMetaType<ManagedObjectList>();
    

    然后我们可以注释XML:

    <method name="GetManagedObjects">
      <arg type="a{oa{sa{sv}}}" name="objects" direction="out">
        <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ManagedObjectList"/>
      </arg>
    </method>
    <signal name="InterfacesAdded">
      <arg type="o" name="object"/>
      <arg type="a{sa{sv}}" name="interfaces">
        <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="InterfaceList"/>
      </arg>
    </signal>
    

    2023-01-19 13:48 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有