Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. how to create custom style class on PyQt4 / PyQt5
QtWS25 Last Chance

how to create custom style class on PyQt4 / PyQt5

Scheduled Pinned Locked Moved Unsolved Language Bindings
5 Posts 2 Posters 2.1k Views
  • 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 Offline
    J Offline
    Jorgen
    wrote on last edited by Jorgen
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • J Offline
        J Offline
        Jorgen
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          1
          • SGaistS SGaist

            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.

            J Offline
            J Offline
            Jorgen
            wrote on last edited by
            #5

            @SGaist thx for the hint. Will look into it

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved