Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.0
-
61c3f3539c3d2d7dc867c3fef0270a2f5c9ed376 (qt/qtbase/dev) 1580c84e1a3c6658f317f7bc78c64575160c1d65 (qt/qtbase/6.0) 76d7d86a3fbe5bb09c5c070ab11567e4f329185b (qt/tqtc-qtbase/tqtc/lts-5.15)
Description
We were composing new styles from our existing custom style and discovered that even though everything compiled there were unexpected problems at runtime if the baseStyle was another QProxyStyle subclass instance.
We made simple example by creating a modified version of the standard Qt styles example. This version creates a simple subclass of QProxyStyle that only changes the pixelMetric for spacing for radio button labels.
#include "norwegianwoodproxystyle.h" #include "norwegianwoodstyle.h" NorwegianWoodProxyStyle::NorwegianWoodProxyStyle() : QProxyStyle(new NorwegianWoodStyle) { setObjectName("NorwegianWoodProxy"); } int NorwegianWoodProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { switch (metric) { case PM_RadioButtonLabelSpacing: return 32; default: return QProxyStyle::pixelMetric(metric, option, widget); } }
The expected behavior is for the new style to be exactly the same as the NorwegianWoodStyle but with a larger indent for radio buttons.
What actually happens is there is no difference between the two styles. This happens because NorwegianWoodProxyStyle::pixelMetric is never called with metric set to PM_RadioButtonLabelSpacing because the lower level QCommonStyle code access to the proxy() method returns the NorwegianWoodStyle instance instead of NorwegianWoodProxyStyle.
The source of the issue is there is no code QProxyStyle constructors or QProxyStyle::setBaseStyle to update any of baseStyle's proxies if the baseStyle of the proxy is-a QProxyStyle.
We already have a patch that resolves the issue. The attached patch is for qtcore based on Qt 5.12.7 but I expect this is the same for 5.15 as well.
Attachments
For Gerrit Dashboard: QTBUG-85556 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
224782,7 | Make QStyle::proxy() always return the leaf proxy | dev | qt/qtbase | Status: MERGED | +2 | 0 |
329828,7 | Fix proxy style to support a proxy as a base style | dev | qt/qtbase | Status: ABANDONED | +1 | 0 |
330811,2 | Make QStyle::proxy() always return the leaf proxy | 6.0 | qt/qtbase | Status: MERGED | +2 | 0 |
330823,2 | Make QStyle::proxy() always return the leaf proxy | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |