Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. uint argument in dbus call with python

uint argument in dbus call with python

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 3 Posters 788 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.
  • L Offline
    L Offline
    l0drex
    wrote on 23 Oct 2022, 10:37 last edited by l0drex
    #1

    I want to call a dbus method that has one parameter of type uint. I couldn't figure out how to do that, since my number always gets passed as an integer.

    Currently, I am calling it like this:

    connection = QDBusConnection.sessionBus()
    message = QDBusMessage.createMethodCall(...)
    message.setArguments([0, ...])
    

    That 0 should be of type uint

    J 1 Reply Last reply 23 Oct 2022, 11:32
    0
    • L l0drex
      23 Oct 2022, 10:37

      I want to call a dbus method that has one parameter of type uint. I couldn't figure out how to do that, since my number always gets passed as an integer.

      Currently, I am calling it like this:

      connection = QDBusConnection.sessionBus()
      message = QDBusMessage.createMethodCall(...)
      message.setArguments([0, ...])
      

      That 0 should be of type uint

      J Offline
      J Offline
      JonB
      wrote on 23 Oct 2022, 11:32 last edited by
      #2

      @l0drex
      Hi. I do not know anything about DBus. But Python does not have any uint type.

      is anything actually going wrong when you pass that 0? I would have thought it would be fine, are you sure this is a problem.

      I see there is a PyPI package for uint at https://pypi.org/project/uint/. But I am not sure it is relevant. to your situation.

      L 1 Reply Last reply 23 Oct 2022, 13:35
      0
      • J JonB
        23 Oct 2022, 11:32

        @l0drex
        Hi. I do not know anything about DBus. But Python does not have any uint type.

        is anything actually going wrong when you pass that 0? I would have thought it would be fine, are you sure this is a problem.

        I see there is a PyPI package for uint at https://pypi.org/project/uint/. But I am not sure it is relevant. to your situation.

        L Offline
        L Offline
        l0drex
        wrote on 23 Oct 2022, 13:35 last edited by
        #3

        @JonB I am pretty sure, since I get the following error when calling that dbus function:
        ValueError: No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'sisssasa{sv}i')
        Using QtDbusViewer, I get the following signature: susssasa{sv}i

        So as far as I understand, my 0 is being passed as an integer. Since the actual function has a uint as argument, it doesn't find it.

        I already tried using ctypes.c_uint(0) instead, but that didn't work since that is seen as an object. I would like to avoid additional dependencies, since otherwise I could just use the dbus python bindings directly...

        J 1 Reply Last reply 23 Oct 2022, 13:44
        0
        • L l0drex
          23 Oct 2022, 13:35

          @JonB I am pretty sure, since I get the following error when calling that dbus function:
          ValueError: No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'sisssasa{sv}i')
          Using QtDbusViewer, I get the following signature: susssasa{sv}i

          So as far as I understand, my 0 is being passed as an integer. Since the actual function has a uint as argument, it doesn't find it.

          I already tried using ctypes.c_uint(0) instead, but that didn't work since that is seen as an object. I would like to avoid additional dependencies, since otherwise I could just use the dbus python bindings directly...

          J Offline
          J Offline
          JonB
          wrote on 23 Oct 2022, 13:44 last edited by
          #4

          @l0drex
          Then How to send unsigned values to dBus from Python ?

          You can use the DBusArgument class to do this by specifying the QMetaType of the argument.

          L 1 Reply Last reply 23 Oct 2022, 20:44
          0
          • J JonB
            23 Oct 2022, 13:44

            @l0drex
            Then How to send unsigned values to dBus from Python ?

            You can use the DBusArgument class to do this by specifying the QMetaType of the argument.

            L Offline
            L Offline
            l0drex
            wrote on 23 Oct 2022, 20:44 last edited by l0drex
            #5

            @JonB
            Thanks, but that is for PyQt5. I am using PySide6, and the API there is very different: https://doc.qt.io/qtforpython/PySide6/QtDBus/QDBusArgument.html
            I currently can't figure out how to do it there.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              friedemannkleint
              wrote on 29 Oct 2022, 20:12 last edited by
              #6

              This is currently tracked in PYSIDE-1904 . There is no good solution yet since PySide6 does not expose QVariant.

              1 Reply Last reply
              1

              1/6

              23 Oct 2022, 10:37

              • Login

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