[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QDockWidget offset?
From:       Tony Arnold <tony.arnold () manchester ! ac ! uk>
Date:       2018-04-11 20:12:55
Message-ID: 1523477564.6687.20.camel () manchester ! ac ! uk
[Download RAW message or body]

[Attachment #2 (text/plain)]

Matic,

No problem. I'm glad you found the solution.

Regards,
Tony.

On Wed, 2018-04-11 at 18:51 +0000, Matic Kukovec wrote:
Hey Tony,

Thanks for the example. I tried it by adding a QGroupBox to the self.verticalLayout_2 \
and the gap was still there! So It was something with the QGroupBox, not the layout!

So I found this post: \
https://stackoverflow.com/questions/43549990/removing-the-title-from-a-qgroupbox#43550049


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:

groupbox.setStyleSheet("QGroupBox{padding-top:0px; margin-top:-25px}")

Thanks again Tony, for pointing me in the right direction!

________________________________
From: PyQt <pyqt-bounces@riverbankcomputing.com> on behalf of Tony Arnold \
                <tony.arnold@manchester.ac.uk>
Sent: Wednesday, April 11, 2018 7:20 PM
To: pyqt@riverbankcomputing.com
Subject: Re: [PyQt] QDockWidget offset?

Matic,


On Wed, 2018-04-11 at 16:49 +0000, Matic Kukovec wrote:
> Hi Tony,
> 
> I set the QGroupBox as the main widget of the QDockWidget like so:
> > self.main_groupbox = data.QGroupBox()
> > self.main_groupbox.setGeometry(0, 0,width, height)
> > # Set it as the main widget
> > self.setWidget(self.main_groupbox)
> 
> I do not know how to add the groupbox to the dockWidgetsContents  as
> you mentioned, can you please give me an example.

I use QtDesigner to create my interface, but here is the code it
generates for the QDockWidget elements:

self.dockWidget = QtWidgets.QDockWidget(MainWindow)
self.dockWidget.setObjectName("dockWidget")
self.dockWidgetContents = QtWidgets.QWidget()
self.dockWidgetContents.setObjectName("dockWidgetContents")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.dataView = Temperature_DataView(self.dockWidgetContents)
self.dataView.setObjectName("dataView")
self.verticalLayout_2.addWidget(self.dataView)
spacerItem2 = QtWidgets.QSpacerItem(20, 40,
QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout_2.addItem(spacerItem2)
self.dockWidget.setWidget(self.dockWidgetContents)

So, this creates a content widget followed by a vbox layout widget with
the content widget as its parent. The widgets I want in the dock are
then added to the vbox layout and finally, the content widget is set as
the dock widget.

Hope this helps.

Regards,
Tony.

> From: Tony Arnold <tony.arnold@manchester.ac.uk>
> Sent: Wednesday, April 11, 2018 6:20 PM
> To: pyqt@riverbankcomputing.com; kukovecmatic@hotmail.com
> Subject: Re: [PyQt] QDockWidget offset?
> 
> 
> Matic,
> 
> 
> On Wed, 2018-04-11 at 14:20 +0000, Matic Kukovec wrote:
> > Hi guys,
> > 
> > I have a QDockWidget onto which I add a QGroupbox. On Windows,
> there
> > are no problems.
> > But on Linux there is border with a gap on top from the windows
> > frame, with the size similar to a system's menubar.
> > To illustrate this I added a screenshot in the attachment that
> shows
> > a QDockWidget that has a QGroupBox added with the 'setWidget'
> > function and a QPushButton added to the QGroupBox.
> > On the left is the Windows example and on the right is the Linux
> > example with the border drawn behind the QPushButton.
> > 
> > How do I get rid of this border on Linux?
> 
> Is your QGroupBox contained within the dockWidgetsContents widget,
> that
> is usually in a QDockWidget and is effectively a layout, or has it
> replaced it? I think you need to keep the dockWidgetsContent and add
> any other widgets to that and not to the QDockWidget directly.
> 
> Your widget structure or the code that creates the QDockWidget
> instance
> would be helpful here.
> 
> Regards,
> Tony.
> 

--

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


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr" bgcolor="#ffffff" text="#2e3436" link="#2a76c6" vlink="#2e3436">
<div>Matic,</div>
<div><br>
</div>
<div>No problem. I'm glad you found the solution.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Tony.</div>
<div><br>
</div>
<div>On Wed, 2018-04-11 at 18:51 &#43;0000, Matic Kukovec wrote:</div>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf \
solid;padding-left:1ex"> <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 type="cite" \
style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"> <br>
<span style="font-size: \
11pt;">groupbox.setStyleSheet(&quot;QGroupBox{padding-top:0px; \
margin-top:-25px}&quot;)</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 \
&lt;pyqt-bounces@riverbankcomputing.com&gt; on behalf of Tony Arnold \
&lt;tony.arnold@manchester.ac.uk&gt;<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>&nbsp;</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 &#43;0000, Matic Kukovec wrote:<br>
&gt; Hi Tony,<br>
&gt; <br>
&gt; I set the QGroupBox as the main widget of the QDockWidget like so:<br>
&gt; &gt; self.main_groupbox = data.QGroupBox()<br>
&gt; &gt; self.main_groupbox.setGeometry(0, 0,width, height)<br>
&gt; &gt; # Set it as the main widget<br>
&gt; &gt; self.setWidget(self.main_groupbox)<br>
&gt;&nbsp; <br>
&gt; I do not know how to add the groupbox to the dockWidgetsContents&nbsp; as<br>
&gt; 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(&quot;dockWidget&quot;)<br>
self.dockWidgetContents = QtWidgets.QWidget()<br>
self.dockWidgetContents.setObjectName(&quot;dockWidgetContents&quot;)<br>
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)<br>
self.verticalLayout_2.setObjectName(&quot;verticalLayout_2&quot;)<br>
self.dataView = Temperature_DataView(self.dockWidgetContents)<br>
self.dataView.setObjectName(&quot;dataView&quot;)<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>
&gt; From: Tony Arnold &lt;tony.arnold@manchester.ac.uk&gt;<br>
&gt; Sent: Wednesday, April 11, 2018 6:20 PM<br>
&gt; To: pyqt@riverbankcomputing.com; kukovecmatic@hotmail.com<br>
&gt; Subject: Re: [PyQt] QDockWidget offset?<br>
&gt;&nbsp; <br>
&gt; <br>
&gt; Matic,<br>
&gt; <br>
&gt; <br>
&gt; On Wed, 2018-04-11 at 14:20 &#43;0000, Matic Kukovec wrote:<br>
&gt; &gt; Hi guys,<br>
&gt; &gt; <br>
&gt; &gt; I have a QDockWidget onto which I add a QGroupbox. On Windows,<br>
&gt; there<br>
&gt; &gt; are no problems.<br>
&gt; &gt; But on Linux there is border with a gap on top from the windows<br>
&gt; &gt; frame, with the size similar to a system's menubar.<br>
&gt; &gt; To illustrate this I added a screenshot in the attachment that<br>
&gt; shows<br>
&gt; &gt; a QDockWidget that has a QGroupBox added with the 'setWidget'<br>
&gt; &gt; function and a QPushButton added to the QGroupBox.<br>
&gt; &gt; On the left is the Windows example and on the right is the Linux<br>
&gt; &gt; example with the border drawn behind the QPushButton.<br>
&gt; &gt; <br>
&gt; &gt; How do I get rid of this border on Linux?<br>
&gt; <br>
&gt; Is your QGroupBox contained within the dockWidgetsContents widget,<br>
&gt; that<br>
&gt; is usually in a QDockWidget and is effectively a layout, or has it<br>
&gt; replaced it? I think you need to keep the dockWidgetsContent and add<br>
&gt; any other widgets to that and not to the QDockWidget directly.<br>
&gt; <br>
&gt; Your widget structure or the code that creates the QDockWidget<br>
&gt; instance<br>
&gt; would be helpful here.<br>
&gt; <br>
&gt; Regards,<br>
&gt; Tony.<br>
&gt; <br>
</div>
</span></font></div>
</blockquote>
<div><span>
<pre>-- <br></pre>
<div>
<div><font size="2"><font color="#3366ff"><b>Tony Arnold</b>&nbsp;MBCS, CITP | Senior \
IT Security Analyst | Directorate of IT Services | G64, Kilburn Building | The \
University of Manchester | Manchester M13 9PL | </font><font \
color="#ff0000">T:</font><font color="#3366ff"> &#43;44 161 275 6093 | </font> <font \
color="#ff0000">M:</font><font color="#3366ff"> &#43;44 773 330 \
0039</font></font></div> </div>
</span></div>
</body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic