Solved How to proxy style QPlastiqueStyle which is a proxy style
-
Qt ver: 5.6.1
OS: Linux, Ubuntu 18.04.3I 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
, myStyle
class does not overridedrawControl
forCE_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'sdrawControl
for both theCE_TabBarTabShape
and theCE_TabBarTabLabel
(which is great!) but that immediately hitsQPlastiqueStyle
's implementation and does not ever get to myStyle
's implementation (which is not great).As a result, the
QTabBar
looks likeQPlastiqueStyle
rather than the customStyle
.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 inheritQPlastiqueStyle
, notQProxyStyle
-
@VRonin thanks for the reply!
Are you implying that I should be linking against
qtstyleplugins
? And deriving fromQPlastiqueStyle
directly? -
You are expanding that class so it would make sense, right?
-
Correct. I'll give that a go, thank you