Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved how to create custom style class on PyQt4 / PyQt5

    Language Bindings
    2
    5
    1546
    Loading More Posts
    • 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.
    • J
      Jorgen last edited by Jorgen

      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.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • J
          Jorgen last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            J 1 Reply Last reply Reply Quote 1
            • J
              Jorgen @SGaist last edited by

              @SGaist thx for the hint. Will look into it

              1 Reply Last reply Reply Quote 0
              • First post
                Last post