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. Send a QObject with QDbus
QtWS25 Last Chance

Send a QObject with QDbus

Scheduled Pinned Locked Moved General and Desktop
qtdbus
6 Posts 2 Posters 1.8k Views
  • 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.
  • M Offline
    M Offline
    marcosbontempo
    wrote on last edited by
    #1

    Hello,

    I wrote a QDBus code able to send and receive QDBusMessage strings. Is there any way to send and receive QObjects too? What is the best way to encapsulate the transfered data ?

    Any tip will be very helpful.
    Thanks.

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

      Hi,

      You can find information about that here

      Hope it helps

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You can find information about that here

        Hope it helps

        M Offline
        M Offline
        marcosbontempo
        wrote on last edited by marcosbontempo
        #3

        Hi @SGaist ,
        Thanks for answering. The link you sent me is exactly what I wanted!
        I'm trying to pass an object created in one of my classes as an argument.

        I have to declare my class with Q_DECLARE_METATYPE macro and call the function qRegisterMetaType, right? Do I have to use the Q_DECLARE_METATYPE macro in the class header?

        The examples are only for structs. I'm trying to do something similar with classes, but without sucess. Have you got an example? I'm a dummie with Qt.

        Thanks!

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

          Q_DECLARE_METATYPE works with classes as well as struct you can follow the example all the same.

          Yes, declare your class and just under the declaration and before the endif call Q_DECLARE_METATYPE

          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
            marcosbontempo
            wrote on last edited by
            #5

            Thanks for the help @SGaist !
            I extended my type, but there was a restriction with QOBject classes. Can't I use any base class with the macro Q_DECLARE_METATYPE?

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

              You can't call Q_DECLARE_METATYPE(MyQObjectDerivedClass) because QObject is not a copyable class

              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

              • Login

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