I'm on KDE Plasma 6.0.2 + Wayland. I need to create a widget that inherits from QWidget
with the Qt::Popup
window flag set and has a natural shadow (i.e., the shadow is drawn by the window manager). Actually, I could inherit my widget from QMenu
(which inherits from QWidget
with the Qt::Popup
window flag set), but there are a lot of methods I don't need. The problem is that my custom widget (which, once again, is inherited from QWidget
with the Qt::Popup
window flag set) doesn't have a natural shadow, while QMenu
does. And I can't understand why, because they are essentially two similar classes.
Got it. In Plasma 6, the presence of a shadow under the popup widget depends on the current style. For the Breeze style (which is default for Plasma 6), you need to add a dynamic property _KDE_NET_WM_FORCE_SHADOW
and set it to true
:
class CustomPopup : public QWidget
{
Q_OBJECT
public:
explicit CustomPopup(QWidget *parent = nullptr)
: QWidget(parent, Qt::Popup)
{
setProperty("_KDE_NET_WM_FORCE_SHADOW", true);
}
};
See here for details.