Important: Please read the Qt Code of Conduct -

how to create custom style class on PyQt4 / PyQt5

  • Hi guys,
    I'm wondering if there is a way to subclass QPlastiqueStyle on PyQt4 and QFusionStyle on PyQt5?
    QProxyStyle is the best choice and is working (but is only available on PyQt5) - so how to subclass and create custom style class on PyQt4?

    Hope someone can help me here?...

    Currently I add Plastique for Qt 4 and Fusion for Qt 5 and apply some custom palette and stylesheets on top.
    But would be nicer to add style sheets and palette directly on overloaded polish method of custom style class.

  • Lifetime Qt Champion


    Check the QStyle documentation for the basics of creating a custom style and using it. It's the same for Qt 4.

    The linked example also shows a nice example using QProxyStyle which might be a better choice depending on what you want to achieve.

    Hope it helps

  • Hi @SGaist thx for the fast reply.
    QProxyStyle is the best choice for PyQt5, but it is not available for PyQt4.
    Maybe there is a way to create a style plugin for my cpp style classes, which I can use afterwards in Python?

  • Lifetime Qt Champion

    The folks from PyQt also provides the tool to generate python bindings from C++ code. You can write you C++ class and create the bindings for it and use it in your Qt application.

  • @SGaist thx for the hint. Will look into it

Log in to reply