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. [PySide6] XDG D-Bus: qt.dbus.integration: Could not connect "org.freedesktop.portal.Request" to nRequestResponse
Forum Updated to NodeBB v4.3 + New Features

[PySide6] XDG D-Bus: qt.dbus.integration: Could not connect "org.freedesktop.portal.Request" to nRequestResponse

Scheduled Pinned Locked Moved Unsolved Qt for Python
pysideqt for python
5 Posts 2 Posters 185 Views 1 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.
  • transistxrT Offline
    transistxrT Offline
    transistxr
    wrote last edited by
    #1

    Hi,

    I'm trying to implement the XDG Portal D-Bus APIs for screencasting using the QtDBus module in PySide6.

    I'm getting this error:

    qt.dbus.integration: Could not connect "org.freedesktop.portal.Request" to nRequestResponse :
    Failed to connect to Response signal for /org/freedesktop/portal/desktop/request/_1_359/colorpycker_bedcade8
    

    Here's the code I have so far, can anyone help me where the error is?

    I have used Bustle and also dbus-monitor to see all the D-Bus Requests and I can see a couple successfull calls with the response that I do require, so why is it failing here? I've also noticed the logs show nRequestResponse instead of onRequestResponse. Not sure what's happening here.

    Here's the relevant code and I've linked to a pastebin of the entire code below if you want to test it:

        def _connect_request_signal(self, request_path: str, method_name: str):
            """Connect to the Response signal for a request"""
            self.current_requests[request_path] = method_name
            
            success = self.bus.connect(
                "org.freedesktop.portal.Desktop",
                request_path,
                "org.freedesktop.portal.Request",
                "Response",
                self,
                "onRequestResponse",
            )
    
            if not success:
                print(f"Failed to connect to Response signal for {request_path}")
    
        @Slot(int, dict)
        def onRequestResponse(self, response_code: int, results: dict):
            """Handle Response signal from portal requests"""
            sender_obj = self.sender()
            if not sender_obj:
                print("No sender object available")
                return
    
            method_name = "unknown"
            request_path_to_remove = None
    
            for path, stored_method in list(self.current_requests.items()):
                if not path.endswith("_handler"):
                    method_name = stored_method
                    request_path_to_remove = path
                    break
    
            print(f"Response for {method_name}: code={response_code}, results={results}")
    
            if response_code != 0:
                error_msg = f"{method_name} failed with code {response_code}"
                self.screencast_failed.emit(error_msg)
                return
    
            if method_name == "CreateSession":
                self.session_handle = results.get("session_handle")
                if self.session_handle:
                    self.session_created.emit(self.session_handle)
                else:
                    self.screencast_failed.emit("No session handle received")
    
            elif method_name == "SelectSources":
                self.sources_selected.emit()
    
            elif method_name == "Start":
                streams = results.get("streams", [])
                restore_token = results.get("restore_token")
    
                if restore_token:
                    print(f"Restore token: {restore_token}")
    
                if streams:
                    self.screencast_started.emit(streams)
                else:
                    self.screencast_failed.emit("No streams received")
    
            if request_path_to_remove and request_path_to_remove in self.current_requests:
                del self.current_requests[request_path_to_remove]
    

    Pastebin to entire file: https://paste.centos.org/view/49a14c2d

    1 Reply Last reply
    0
    • F Offline
      F Offline
      friedemannkleint
      wrote last edited by
      #2

      A truncation like "nRequestResponse" instead of "onRequestResponse" typically means the SLOT function is missing. Probably SLOT("onRequestResponse") needs to be specified in the connect statement ( see https://doc.qt.io/qtforpython-6/tutorials/basictutorial/signals_and_slots.html#tutorial-signals-and-slots ).

      1 Reply Last reply
      0
      • transistxrT Offline
        transistxrT Offline
        transistxr
        wrote last edited by
        #3

        I've tried a variety of options but none of them work.

        @Slot()
        def on_session_created(self):
        
            self.bus.connect(
                "org.freedesktop.portal.Desktop",
                self.object_path,
                "org.freedesktop.portal.Request",
                "Response",
                self,
                SLOT("select_sources(uint, QVariantMap)"),
            )
        
        @Slot(int, dict)
        def select_sources(response: int, results: dict):
            print(f"Received response: {response}, with results: {results}")
        

        I have tried:
        SLOT("select_sources(uint, QVariantMap)"), SLOT("select_sources"), just passing a method and many other things.

        https://paste.centos.org/view/f3a16c4e

        1 Reply Last reply
        0
        • F Offline
          F Offline
          friedemannkleint
          wrote last edited by
          #4

          Try decorating with string types:

           @Slot("uint", "QVariantMap")
              def select_sources()
          
          transistxrT 1 Reply Last reply
          0
          • F friedemannkleint

            Try decorating with string types:

             @Slot("uint", "QVariantMap")
                def select_sources()
            
            transistxrT Offline
            transistxrT Offline
            transistxr
            wrote last edited by
            #5

            @friedemannkleint This did not work either, although I wasn't getting any errors as such

            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