Qt Forum

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

    Solved How to proxy style QPlastiqueStyle which is a proxy style

    General and Desktop
    2
    5
    188
    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.
    • M
      Matt Penman last edited by

      Qt ver: 5.6.1
      OS: Linux, Ubuntu 18.04.3

      I have a case where I'm trying to apply a style to a widget with a complex proxy style hierarchy:

      Style inherits QProxyStyle
          baseStyle = QPlastiqueStyle
      
      QPlastique inherits QProxyStyle
          baseStyle = QWindowsStyle
      

      The widget in question is a QTabBar, my Style class does not override drawControl for CE_TabBarTab, so the chain of style class traversal should be:

      Style -> QProxyStyle -> QPlastiqueStyle -> QProxyStyle -> QWindowsStyle -> QCommonStyle

      to the implementation of:

          case CE_TabBarTab:
              if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
                  proxy()->drawControl(CE_TabBarTabShape, tab, p, widget);
                  proxy()->drawControl(CE_TabBarTabLabel, tab, p, widget);
              }
              break;
      

      As you can see, QCommonStyle immediately calls the proxy style's drawControl for both the CE_TabBarTabShape and the CE_TabBarTabLabel (which is great!) but that immediately hits QPlastiqueStyle's implementation and does not ever get to my Style's implementation (which is not great).

      As a result, the QTabBar looks like QPlastiqueStyle rather than the custom Style.

      Is there a prescribed workflow that I'm missing here? In qt4 Style inheritance chain is much simpler (of course):

      Style -> QPlastiqueStyle -> QWindowsStyle -> QCommonStyle

      Any pointers would be greatly appreciated :)

      Thanks,
      Matt

      V 1 Reply Last reply Reply Quote 0
      • V
        VRonin @Matt Penman last edited by

        @matt-penman said in How to proxy style QPlastiqueStyle which is a proxy style:

        In qt4 Style inheritance chain is much simpler (of course):
        Style -> QPlastiqueStyle -> QWindowsStyle -> QCommonStyle

        This still works in Qt5 with a minor extra step that is transparent to you why do you think it's impossible?

        What I'm saying is that Style should inherit QPlastiqueStyle, not QProxyStyle

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 0
        • M
          Matt Penman last edited by

          @VRonin thanks for the reply!

          Are you implying that I should be linking against qtstyleplugins? And deriving from QPlastiqueStyle directly?

          1 Reply Last reply Reply Quote 0
          • V
            VRonin last edited by

            You are expanding that class so it would make sense, right?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply Reply Quote 0
            • M
              Matt Penman last edited by

              Correct. I'll give that a go, thank you

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