Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt DBus XML howto
Forum Updated to NodeBB v4.3 + New Features

Qt DBus XML howto

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 612 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • nestoracN Offline
    nestoracN Offline
    nestorac
    wrote on last edited by
    #1

    Hello, I want to develop a Qt5 QtDBus app GUI, for safely erasing HDD's. They have told me that QtDBus is the best way, but I don't know exactly where to start. BTW, the have told be I should use XML files and parse them using qdbusxml2cpp, but I don't know how this works.

    Could anyone please explain me more or less how QtDBus XML files work? Thank you!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you already went through the QtDBus module documentation ?

      Beside explaining the concepts it also describe the tools and there are several examples you can check.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MatiF
        wrote on last edited by
        #3

        Hi!

        Maybe a little late, but I want to share it with future users on how to integrate DBus in Qt.

        When you need to send objects via DBus, your class must be described in XML so that Qt can generate the interface and adaptor for sending and receiving those objects. For example, with MyClass defined, you can run qdbuscpp2xml MyClass.h -o xmlMyClass.xml. If MyClass methods return or get standard parameters (supported types listed here: https://doc.qt.io/qt-6/qdbustypesystem.html), qdbuscpp2xml will generate everything for you. However, if the methods involve unsupported types, such as another custom object, you'll need to manually edit the XML file.

        Once your class is described in the XML file, use qdbusxml2cpp to generate the interface and adaptor, then connect them to the Bus. From there, you can use the interface to send and receive data.

        I haven't gone into full detail here to keep the comment concise, but I’ve written a blog post that covers this process more thoroughly, including how to edit the XML file for qdbusxml2cpp to generate a complete interface and adaptor. The post is based on Qt6, but it should also work with Qt5: https://scythe-studio.com/en/blog/how-to-use-d-bus-with-qt-6

        I hope this helps!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved