Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to proxy style QPlastiqueStyle which is a proxy style
Forum Updated to NodeBB v4.3 + New Features

How to proxy style QPlastiqueStyle which is a proxy style

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 652 Views 1 Watching
  • 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 Offline
    M Offline
    Matt Penman
    wrote on last edited by
    #1

    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

    VRoninV 1 Reply Last reply
    0
    • M Matt Penman

      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

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @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
      0
      • M Offline
        M Offline
        Matt Penman
        wrote on last edited by
        #3

        @VRonin thanks for the reply!

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

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          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
          0
          • M Offline
            M Offline
            Matt Penman
            wrote on last edited by
            #5

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

            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