QLayout setSpacing and setContentsMargin gives black color
-
I am trying to use setSpacing and setContentsMargin for my QLayout.
Both of these give a transparent view on Linux. However, these functions give a black border and space in Windows. I am wondering how can I use these functions on windows side transparently?
Thanks
-
Those two function should neither create a black nor a transparent space somewhere except you either use a custom QPalette or style sheets. So please provide a minimal, compilable example to reproduce your problem.
-
@Christian-Ehrlicher Here is a simple code snippet I am using:
QLayout* layout = this->layout(); layout->setContentsMargins(10,10,10,10); QHBoxLayout* hBox = qobject_cast<QHBoxLayout*>(layout); hBox->addWidget(viewerWidget);
The resulted window Margins are in black color on Windows, however on Linux they are transparent.
-
The resulted window Margins are in black color on Windows, however on Linux they are transparent.
This is not correct - they're in the background color which you somewhere changed (at least I would guess you do so). Please provide a fully, compilable example.
-
Layout is not a visual element, so it doesn't have color nor is it transparent. Whatever you see as black or transparent is the widget the layout is set on, so your example tells nothing.
If you set your widget to be transparent via window flags it depends on the platform plugin and window manager if they implement that. On recent Windows you can't achieve transparent widgets (or at least the dedicated flags for it don't work anymore), and what you get is a black window background of the native window.