<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hey Tony,<br>
<br>
Thanks for the example. I tried it by adding a QGroupBox to the self.<font size="2"><span style="font-size:11pt;">verticalLayout_2</span></font> and the gap was still there! So It was something with the QGroupBox, not the layout!<br>
<br>
So I found this post: <a href="https://stackoverflow.com/questions/43549990/removing-the-title-from-a-qgroupbox#43550049" id="LPNoLP376971">
https://stackoverflow.com/questions/43549990/removing-the-title-from-a-qgroupbox#43550049</a><br>
<br>
Long story short: It is a bug with the style on Linux. A workaround is to just offset the margin of the groupbox, like for example so:<br>
<blockquote style="margin-top: 0px; margin-bottom: 0px;"><br>
<span style="font-size: 11pt;">groupbox.setStyleSheet("QGroupBox{padding-top:0px; margin-top:-25px}")</span><br>
</blockquote>
<br>
Thanks again Tony, for pointing me in the right direction!<br>
<br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> PyQt <pyqt-bounces@riverbankcomputing.com> on behalf of Tony Arnold <tony.arnold@manchester.ac.uk><br>
<b>Sent:</b> Wednesday, April 11, 2018 7:20 PM<br>
<b>To:</b> pyqt@riverbankcomputing.com<br>
<b>Subject:</b> Re: [PyQt] QDockWidget offset?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Matic,<br>
<br>
<br>
On Wed, 2018-04-11 at 16:49 +0000, Matic Kukovec wrote:<br>
> Hi Tony,<br>
> <br>
> I set the QGroupBox as the main widget of the QDockWidget like so:<br>
> > self.main_groupbox = data.QGroupBox()<br>
> > self.main_groupbox.setGeometry(0, 0,width, height)<br>
> > # Set it as the main widget<br>
> > self.setWidget(self.main_groupbox)<br>
>  <br>
> I do not know how to add the groupbox to the dockWidgetsContents  as<br>
> you mentioned, can you please give me an example.<br>
<br>
I use QtDesigner to create my interface, but here is the code it<br>
generates for the QDockWidget elements:<br>
<br>
self.dockWidget = QtWidgets.QDockWidget(MainWindow)<br>
self.dockWidget.setObjectName("dockWidget")<br>
self.dockWidgetContents = QtWidgets.QWidget()<br>
self.dockWidgetContents.setObjectName("dockWidgetContents")<br>
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)<br>
self.verticalLayout_2.setObjectName("verticalLayout_2")<br>
self.dataView = Temperature_DataView(self.dockWidgetContents)<br>
self.dataView.setObjectName("dataView")<br>
self.verticalLayout_2.addWidget(self.dataView)<br>
spacerItem2 = QtWidgets.QSpacerItem(20, 40,<br>
QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)<br>
self.verticalLayout_2.addItem(spacerItem2)<br>
self.dockWidget.setWidget(self.dockWidgetContents)<br>
<br>
So, this creates a content widget followed by a vbox layout widget with<br>
the content widget as its parent. The widgets I want in the dock are<br>
then added to the vbox layout and finally, the content widget is set as<br>
the dock widget.<br>
<br>
Hope this helps.<br>
<br>
Regards,<br>
Tony.<br>
<br>
> From: Tony Arnold <tony.arnold@manchester.ac.uk><br>
> Sent: Wednesday, April 11, 2018 6:20 PM<br>
> To: pyqt@riverbankcomputing.com; kukovecmatic@hotmail.com<br>
> Subject: Re: [PyQt] QDockWidget offset?<br>
>  <br>
> <br>
> Matic,<br>
> <br>
> <br>
> On Wed, 2018-04-11 at 14:20 +0000, Matic Kukovec wrote:<br>
> > Hi guys,<br>
> > <br>
> > I have a QDockWidget onto which I add a QGroupbox. On Windows,<br>
> there<br>
> > are no problems.<br>
> > But on Linux there is border with a gap on top from the windows<br>
> > frame, with the size similar to a system's menubar.<br>
> > To illustrate this I added a screenshot in the attachment that<br>
> shows<br>
> > a QDockWidget that has a QGroupBox added with the 'setWidget'<br>
> > function and a QPushButton added to the QGroupBox.<br>
> > On the left is the Windows example and on the right is the Linux<br>
> > example with the border drawn behind the QPushButton.<br>
> > <br>
> > How do I get rid of this border on Linux?<br>
> <br>
> Is your QGroupBox contained within the dockWidgetsContents widget,<br>
> that<br>
> is usually in a QDockWidget and is effectively a layout, or has it<br>
> replaced it? I think you need to keep the dockWidgetsContent and add<br>
> any other widgets to that and not to the QDockWidget directly.<br>
> <br>
> Your widget structure or the code that creates the QDockWidget<br>
> instance<br>
> would be helpful here.<br>
> <br>
> Regards,<br>
> Tony.<br>
> <br>
-- <br>
Tony Arnold MBCS, CITP | Senior IT Security Analyst | Directorate of IT Services | G64, Kilburn Building | The University of Manchester | Manchester M13 9PL | T: +44 161 275 6093 | M: +44 773 330 0039<br>
_______________________________________________<br>
PyQt mailing list    PyQt@riverbankcomputing.com<br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div>
</span></font></div>
</body>
</html>