K'fusion, or descending Fusion from KStyle

René J.V. Bertin rjvbertin at gmail.com
Fri Aug 30 23:35:06 BST 2019


Hi,

I had a recent run-in with a style hint that should actually be a platform-specific property (à la AA_DontUseNativeMenuBar; see QTBUG-77928) and then realised it could be useful to have a Fusion override style that inherits KStyle, given that more and more applications seem to adopt this style in order to have a consistent look (that just works) everywhere. Experience with the "native" Mac style suggests that Qt will give precedence to styles provided by plugins over styles provided in libQt5Widgets, so overriding a built-in style should indeed be possible.

We introduced KStyle inheritance In QtCurve with a simple `using` construct: when built with KDE support the style class will inherit KStyle, else it will inherit QCommonStyle.

It turns out that the Fusion style class invokes a protected QCommonStyle ctor that takes a newly allocated instance of the associated private class; KStyle itself inherits QCommonStyle but not this method. What are the options here, short of extending KStyle and using a "hand-written" d-pointer in the Fusion style class? I tried `d_ptr.reset(new PrivateFoo)` but that leads to a runtime error about reparenting an instance with a parent from a different thread followed by a crash.

Thanks,
R.


More information about the Plasma-devel mailing list