Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-98564

Correctly initializing GDK when using Qt

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12, 5.15, 6.x
    • Fix Version/s: None
    • Component/s: GUI: Look'n'Feel
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      Hello,
      consider the following code:

      #include <QApplication>
      #include <QLabel>
      #include <dlfcn.h>
      
      int main(int argc, char** argv)
      {
        using gdk_init_check_ptr = void *(*)(int*, char***);
        auto gdk = dlopen("libgdk-x11-2.0.so.0", RTLD_LAZY | RTLD_LOCAL);
        auto gdk_init_check = (gdk_init_check_ptr)dlsym(gdk, "gdk_init_check");
      
        gdk_init_check(nullptr, nullptr);
      
        QApplication app{argc, argv};
      
        QLabel label{"foo"};
        label.show();
      
        return app.exec();
      }
      

      It will work fine if the QT_QPA_PLATFORMTHEME is not gtk3.
      Otherwise, it either hangs (if gdk_init_check comes before QApplication) or crashes (if gdk_init_check comes after), likely because QGtk3 calls it too (through gtk_init).
      Sadly qgtk3 is the default platform theme on Ubuntu means that's where are a lot of users.

      What are my options to make sure that things work correctly no matter my user's platform themes ? My app loads external plug-ins from separate vendors and some require a GTK context to be initialized.

        Attachments

        1. answer.text
          0.7 kB
          Ilya Fedin
        2. QTBUG-98564.tar.gz
          0.8 kB
          Liang Qi
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            jcelerier Jean-Michaƫl Celerier
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes