Using qgtk2 plugin with Qt 5.9?



  • Is it possible to use the qgtk2 plugin from Qt 5.6.2 with newer versions of Qt, such as Qt 5.9.1? If so how can this be achieved?

    Just to give some background on why I ask this; in Qt 5.8.0 the qgtk2 plugin, which emulates the system GTK2 theme on Linux, was replaced by a new qgtk3 plugin, which is supposed to emulate the system's GTK3 theme. Unfortunately the new plugin is not very robust and fails to correctly emulate the system GTK3 theme on many desktop environments, and particularly on Cinnamon. I've continued to use Qt 5.6.2 on Linux, since that was the last version that came with the qgtk2 plugin, and was therefore the last version that worked correctly on Linux. However, Qt 5.6.2 is getting quite old and issues are starting to arise, for example it no longer compiles correctly on the latest release of Arch Linux because Qt 5.6.2 requires openssl 1.0 and Arch now ships with openssl 1.1, which causes compilation errors. I'd therefore like to switch to Qt 5.9.1 on Linux, but continue to use the qgtk2 plugin from 5.6.2 so that the system GTK is correctly emulated.


  • Lifetime Qt Champion

    Hi,

    What you can try is to copy the gtk2 plugin over to your 5.9.1 and modify the platformthemes.pro file to make it build the plugin.

    Hope it helps



  • I tried deleting the Qt5.9.0/qtbase/src/plugins/platformthemes/gtk3 folder and replacing it with the qgtk2 folder from Qt 5.6.2. I then modified the 5.9.0 platformthemes.pro to change gtk3 to gtk2:

    TEMPLATE = subdirs
    QT_FOR_CONFIG += widgets-private
    
    qtHaveModule(widgets):qtConfig(gtk2): SUBDIRS += gtk2
    

    After configuration it generated this makefile, but it failed to build:

    Makefile:670: recipe for target 'sub-plugins-make_first' failed
    make[2]: *** [sub-plugins-make_first] Error 2
    make[2]: Leaving directory '/home/user/Qt/Qt5.9.0-S64/qtbase/src'
    Makefile:49: recipe for target 'sub-src-make_first' failed
    make[1]: *** [sub-src-make_first] Error 2
    make[1]: Leaving directory '/home/user/Qt/Qt5.9.0-S64/qtbase'
    Makefile:83: recipe for target 'module-qtbase-make_first' failed
    make: *** [module-qtbase-make_first] Error 2
    

    I also tried using the platformthemes.pro from Qt 5.6.2:

    TEMPLATE = subdirs
    
    contains(QT_CONFIG, gtk2): SUBDIRS += gtk2
    

    While Qt did compile with that, the qgtk2 plugin wasn't actually built. I'm not sure how to get it working.


  • Lifetime Qt Champion

    No need to delete anything.

    You contains line won't work, there's no detection done for GTK2 anymore. Since you want to build it anyway, just keep the SUBDIRS part.



  • I changed the platformthemes.pro to the below:

    TEMPLATE = subdirs
    
    SUBDIRS += gtk2
    

    However, it fails to build with the same errors as before:

    Makefile:670: recipe for target 'sub-plugins-make_first' failed
    make[2]: *** [sub-plugins-make_first] Error 2
    make[2]: Leaving directory '/home/user/Qt/Qt5.9.0-S64/qtbase/src'
    Makefile:49: recipe for target 'sub-src-make_first' failed
    make[1]: *** [sub-src-make_first] Error 2
    make[1]: Leaving directory '/home/user/Qt/Qt5.9.0-S64/qtbase'
    Makefile:83: recipe for target 'module-qtbase-make_first' failed
    make: *** [module-qtbase-make_first] Error 2
    

    I think the problem is actually in the qgtk2.pro file and is probably the below two lines. I assume QT_CFLAGS_QGTK2 and QT_LIBS_QGTK2 are no longer defined in Qt 5.9.0:

    QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTK2
    LIBS += $$QT_LIBS_QGTK2
    

    I might have to give up on using qgtk2 with Qt 5.9.0.

    I'm thinking of reporting the qtk3 issues as a bug. I've been testing it with a variety of distributions and desktop environments and it does seem to have a lot of problems, and produces a number of different errors. I might write up a bug report with the errors and some screenshots of it failing to emulate the system GTK3 theme.


  • Lifetime Qt Champion

    Take a look at the content of the equivalent GTK3 flags and adapt them for GTK2.

    Or just configure an older version of Qt with the GTK2 plugin and copy the values you can find.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.