Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Fail to build qtstyleplugins



  • Hi everyone,

    I am porting an application from Qt 4.8.6 to Qt 5.9.5. The application was using QGtkStyle, but it has been removed from qt5-base.

    It seems that I could retrieve it in the qtstyleplugins, but I fail to build the last code available from the github repository (or even the 5.0.0 tag version, that does not seems to provide Gtk Style anyway).
    I get this error :

    error: unrecognized command line option ā€˜-std=c++1zā€™
    

    I don't understand who is telling him to build with this c++ standard, and I fail to force it to -std=c++11 !
    I am on Debian 8 64 bits, g++ 4.9.2 and Qt 5.9.5 as stated before.


  • Lifetime Qt Champion

    Where did you get the code for the style pluginfrom? How did you try to compile the plugin?



  • Hi Christian !

    I got it from https://github.com/qt/qtstyleplugins
    I try to compile it the simplest way : qmake then make.

    I finally managed to get it built, by manually editing the generated Makefile that contained -std=c++1z and replaced it by -std=c++11.
    (If I run qmake again, these manual modifications are lost of course)
    So this point is non-blocking anymore but not understood by the way.

    I now try to use it.
    So I copied the libs from plugins directory to my Qt installation folder, plugins directory.

    qDebug() << QStyleFactory::keys();
    

    returns the good list with new plugin styles :

    ("bb10dark", "bb10bright", "cleanlooks", "gtk2", "cde", "motif", "plastique", "Windows", "Fusion")
    

    I tried to use the new styles :

    QApplication::setStyle(QStyleFactory::create("cleanlooks"));
    

    It Works !

    But not the one i want to use :(

    QApplication::setStyle(QStyleFactory::create("gtk2"));
    

    Makes my application crash on startup with the following logs :

    (testQStyle:1875): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'
    
    (testQStyle:1875): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
    
    (testQStyle:1875): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
    
    (testQStyle:1875): GLib-GObject-WARNING **: invalid (NULL) pointer instance
    
    (testQStyle:1875): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (testQStyle:1875): GLib-GObject-WARNING **: invalid (NULL) pointer instance
    
    (testQStyle:1875): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (testQStyle:1875): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplay'
    
    (testQStyle:1875): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
    
    (testQStyle:1875): GLib-GObject-CRITICAL **: g_type_register_static: assertion 'parent_type > 0' failed
    
    (testQStyle:1875): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
    
    (testQStyle:1875): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
    

  • Lifetime Qt Champion

    Hi
    Does a normal gtk2 app run ?
    I mean unless you did something like
    apt-get install gtk2.0
    or the SO files comes include im not sure it can just work without the expected versions of the support files.

    i would do some ldd on the SO plugin to see if it has all it needs from the system.



  • What do you call a normal gtk2 app ? My application that was using QGtkStyle with Qt 4.8.6 run on the same machine.

    I think it got everything he need from the system :

    ldd libqgtk2style.so 
    	linux-vdso.so.1 (0x00007ffe5e33a000)
    	libgtk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007f69616b8000)
    	libgdk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007f6961402000)
    	libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f69611f5000)
    	libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f6960fce000)
    	libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f6960cb8000)
    	libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f6960a96000)
    	libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f696070d000)
    	libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f69604f7000)
    	libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f69602a9000)
    	libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f6960056000)
    	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f695fd46000)
    	libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f695fb09000)
    	libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f695f85f000)
    	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f695f51c000)
    	libQt5Widgets.so.5 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libQt5Widgets.so.5 (0x00007f695ece8000)
    	libQt5Gui.so.5 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libQt5Gui.so.5 (0x00007f695e537000)
    	libQt5Core.so.5 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libQt5Core.so.5 (0x00007f695ddfa000)
    	libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007f695db51000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f695d934000)
    	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f695d629000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f695d328000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f695d112000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f695cd67000)
    	libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f695cb63000)
    	libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f695c960000)
    	libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f695c75d000)
    	libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f695c557000)
    	libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f695c34d000)
    	libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f695c14a000)
    	libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f695bf39000)
    	libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f695bd2f000)
    	libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f695bb24000)
    	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f695b912000)
    	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f695b710000)
    	libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f695b462000)
    	libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f695b23b000)
    	libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f695b037000)
    	libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f695ae2d000)
    	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f695ac0b000)
    	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f695a9f0000)
    	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f695a7e8000)
    	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f695a5c3000)
    	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f695a3ac000)
    	libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f695a155000)
    	libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007f6959f4c000)
    	libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f6959d43000)
    	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f6959ad5000)
    	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f69598ac000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f69596a8000)
    	libicui18n.so.56 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libicui18n.so.56 (0x00007f695920f000)
    	libicuuc.so.56 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libicuuc.so.56 (0x00007f6958e57000)
    	libicudata.so.56 => /home/julien/Qt5.9.5/5.9.5/gcc_64/plugins/styles/../../lib/libicudata.so.56 (0x00007f6957474000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f6961f36000)
    	libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f6957244000)
    	libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f6956f71000)
    	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f6956d6d000)
    	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f6956b68000)
    	libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f6956939000)
    	libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f6956731000)
    

  • Lifetime Qt Champion

    @achard-ju
    Hi
    Ok so we are sure the gtk2 part is present.
    Also the ldd looks good.

    I was wondering if we can get more info with
    https://doc.qt.io/qt-5/debug.html
    setting the QT_DEBUG_PLUGINS and run the app to see if we can find out
    if anything fails to load.



  • Hi !

    I don't found any useful information with QT_DEBUG_PLUGINS enabled ...
    It's a bit long so i put it to pastebin.

    By the way, it seems to only crash in the test app I created to test it.
    It does not crash in my full application ! (but the execution environment of this one is much more complex to explain)

    Soooooo, now I want to reproduce the previous behavior. But i don't really understand how to achieve this with the new system.
    The previous behavior was to subclass QGtkSyle and reimplement only one virtual method : drawPrimitive.

    void CEASITesterStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *widget) const
    {
        switch (pe)
        {
        case PE_FrameFocusRect:
            break;
        case PE_Frame:
        case PE_PanelItemViewRow:
        case PE_PanelItemViewItem:
            QCommonStyle::drawPrimitive(pe, opt, p, widget);
            break;
        default:
            QGtkStyle::drawPrimitive(pe, opt, p, widget);
            break;
        }
    }
    

    I was thinking to subclass QProxyStyle, and call QProxyStyle::drawPrimitive instead of QGtkStyle.
    As my QStyle will be the gtk one, i don't need the proxy to do anything special.

    But I don't know how to replace the call to QCommonStyle, in the specific case it was done before...


  • Lifetime Qt Champion

    Hi
    It also seems to load the gtk3 so files also
    gcc_64/plugins/platformthemes/libqgtk3.so"
    and then give errors
    (testQStyle:28029): GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'
    loading styles/libqgtk2style.so"
    I wondering if they try to register the same ids/object or something.

    Hmm. i would think you would use
    QProxyStyle::drawPrimitive to forward to the normal drawing but if that is 100% the same effect
    as calling commonstyle in the old way, im not sure.

    But i did check it does not give infinite recursion :)
    void MyProxyStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
    {
    QProxyStyle::drawPrimitive(pe, opt,p,w);
    }



  • Hi,

    that's what I do, but my interrogation is on the specific case :

    Somewhere in my code :

    QApplication::setStyle(QStyleFactory::create("gtk2"));
    

    And in my Proxy class :

    void CMyProxyStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *widget) const
    {
        switch (pe)
        {
        case PE_FrameFocusRect:
            break;
        case PE_Frame:
        case PE_PanelItemViewRow:
        case PE_PanelItemViewItem:
            //QCommonStyle::drawPrimitive(pe, opt, p, widget);
            //Here I want to use the CommonStyle to draw these primitives, so how can I replace this ?
            break;
        default:
            //QGtkStyle::drawPrimitive(pe, opt, p, widget);
            //Here I want to use the GtkStyle to draw these primitives, so I replaced it by :
            QProxyStyle::drawPrimitive(element, option, painter, widget);
            break;
        }
    }
    

Log in to reply