Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QX11Info::display() and QX11Info::appRootWindow() replacement
Forum Updated to NodeBB v4.3 + New Features

QX11Info::display() and QX11Info::appRootWindow() replacement

Scheduled Pinned Locked Moved Solved Qt 6
5 Posts 2 Posters 1.3k 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.
  • Jonas KvingeJ Offline
    Jonas KvingeJ Offline
    Jonas Kvinge
    wrote on last edited by Jonas Kvinge
    #1

    Hi,

    QX11Extras has been removed with Qt 6: https://bugreports.qt.io/browse/QTBUG-83251
    Is there a better approach than using private Qt GUI (QPlatformNativeInterface)?

    This code works, but it depends on private Qt 6 GUI API:

    Display *X11Display() {
    
      if (!qApp) return nullptr;
    
      QPlatformNativeInterface *native = qApp->platformNativeInterface();
      if (!native) return nullptr;
    
      void *display = native->nativeResourceForIntegration("display");
      return reinterpret_cast<Display*>(display);
    
    }
    
    quint32 AppRootWindow() {
    
      if (!qApp) return 0;
    
      QPlatformNativeInterface *native = qApp->platformNativeInterface();
      if (!native) return 0;
    
      QScreen *screen = QGuiApplication::primaryScreen();
      if (!screen) return 0;
    
      return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("rootwindow", screen)));
    
    }
    
    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      As mentioned by the bug report:

      Should just use native APIs. Don't be afraid to mix and match. Qt can't (and shouldn't) do everything, and using Qt with other platform or 3rd party libraries should be possible and easy.

      Both those methods just make calls to xlib you can do manually

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      Jonas KvingeJ 1 Reply Last reply
      0
      • VRoninV VRonin

        As mentioned by the bug report:

        Should just use native APIs. Don't be afraid to mix and match. Qt can't (and shouldn't) do everything, and using Qt with other platform or 3rd party libraries should be possible and easy.

        Both those methods just make calls to xlib you can do manually

        Jonas KvingeJ Offline
        Jonas KvingeJ Offline
        Jonas Kvinge
        wrote on last edited by
        #3

        @VRonin
        I need the existing connection, Qt does XOpenDisplay() in this case, how do I get the pointer to that connection?
        For the root window I can use DefaultRootWindow() but I still need the connection.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          If I'm not mistaken you can get the default connection by passing NULL as the display name but this is a question better suited for the Xlib forum

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • Jonas KvingeJ Offline
            Jonas KvingeJ Offline
            Jonas Kvinge
            wrote on last edited by
            #5

            @VRonin
            You can't get the connection, since Qt holds it. But there is a new interface added as of Qt 6.2 to get it, see:
            See: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f5203eeada83bbe8e316a5188e24636af3e83b09

            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