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. Get XCB connection for QWindow
Qt 6.11 is out! See what's new in the release blog

Get XCB connection for QWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k 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.
  • A Offline
    A Offline
    adwn
    wrote on last edited by
    #1

    How do I get the XCB connection (xcb_connection_t*) for a given QWindow in Qt5 on X11?

    Right now I'm using QX11Info::connection() to retrieve this pointer, but that depends on libQt5X11Extras.so, which might not be available on every target system. Alternatively, I could use QPlatformNativeInterface::nativeResourceForWindow() with "connection" as the first argument, but QPlatformNativeInterface is non-stable and might change between minor Qt releases.

    Background: I'm integrating a wgpu-based renderer in a Qt application and need the native handle of the QWindow (window ID and connection pointer) to create the swapchain surface. This is working so far, but I'd like to remove the dependency on libQt5X11Extras, if possible.

    Any help would be greatly appreciated.

    jsulmJ 1 Reply Last reply
    0
    • A adwn

      How do I get the XCB connection (xcb_connection_t*) for a given QWindow in Qt5 on X11?

      Right now I'm using QX11Info::connection() to retrieve this pointer, but that depends on libQt5X11Extras.so, which might not be available on every target system. Alternatively, I could use QPlatformNativeInterface::nativeResourceForWindow() with "connection" as the first argument, but QPlatformNativeInterface is non-stable and might change between minor Qt releases.

      Background: I'm integrating a wgpu-based renderer in a Qt application and need the native handle of the QWindow (window ID and connection pointer) to create the swapchain surface. This is working so far, but I'd like to remove the dependency on libQt5X11Extras, if possible.

      Any help would be greatly appreciated.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @adwn said in Get XCB connection for QWindow:

      libQt5X11Extras.so, which might not be available on every target system

      It should be available on all systems which have X11.
      Of course it will not be available on system without X11, but there you also can't use XCB connection as there is no such thing. So, don't know what the problem is?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      1
      • jsulmJ jsulm

        @adwn said in Get XCB connection for QWindow:

        libQt5X11Extras.so, which might not be available on every target system

        It should be available on all systems which have X11.
        Of course it will not be available on system without X11, but there you also can't use XCB connection as there is no such thing. So, don't know what the problem is?

        A Offline
        A Offline
        adwn
        wrote on last edited by adwn
        #3

        @jsulm Available, yes, but not necessarily installed. For example, on Ubuntu 20.04, none of the other Qt packages seems to depend on libqt5x11extras, even on X11 systems. It's not a show-stopper, because the user can manually install this package after getting a cryptic error message when trying to launch my app, but it's a small annoyance I'd like to avoid.

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

          Hi,

          How is your application installed ?

          One alternative is to embed that code directly into your application with proper credit given to that piece.

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

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            How is your application installed ?

            One alternative is to embed that code directly into your application with proper credit given to that piece.

            A Offline
            A Offline
            adwn
            wrote on last edited by
            #5

            @SGaist said in Get XCB connection for QWindow:

            How is your application installed ?

            It's a single executable which is copied to the target machine :-)

            One alternative is to embed that code directly into your application with proper credit given to that piece.

            The QX11Info::connection() method I'm using is essentially this code:

            QPlatformNativeInterface *native = qApp->platformNativeInterface();
            void *connection = native->nativeResourceForIntegration(QByteArray("connection"));
            

            Unfortunately, that depends on QPlatformNativeInterface. So if I want to call a method on this instance, I have to include qpa/qplatformnativeinterface.h which is unstable and which might cause the application to break if the user has installed Qt 5.15 instead of 5.12, for example.

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

              That's one risk indeed.

              One thing you also have to take into account is that the various extras modules have been removed in Qt 6y

              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