Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to proxy style QPlastiqueStyle which is a proxy style



  • 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



  • @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



  • @VRonin thanks for the reply!

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



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



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


Log in to reply