On Mon, Oct 11, 2010 at 2:21 PM, Hans-Peter Jansen <span dir="ltr"><<a href="mailto:hpj@urpla.net" target="_blank">hpj@urpla.net</a>></span> wrote:<br><div class="gmail_quote"><div><div class="h5"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>On Monday 11 October 2010, 17:58:35 John Wiggins wrote:<br>
> On Mon, Oct 11, 2010 at 10:33 AM, Hans-Peter Jansen <<a href="mailto:hpj@urpla.net" target="_blank">hpj@urpla.net</a>><br>
wrote:<br>
> > On Monday 11 October 2010, 16:17:21 John Wiggins wrote:<br>
> > > Hello,<br>
> > ><br>
> > > I'm laying out part of the UI for my app using a QMainWindow with<br>
> > > no central widget and 4 dock widgets. I'd like the dock widgets<br>
> > > to be sized proportionally to each other but they seem to ignore<br>
> > > the value returned by sizeHint(). Am I missing something?<br>
<br>
</div>You could try to subclass the QLabels and implement sizeHint for them,<br>
leaving _ViewContainer alone (size wise).. Let us know, if that helps.<br>
<br>
Since you have QMainWindows in each of your dock widgets, the outcome is<br>
still hard to predict. You may want to reduce your example to the bare<br>
minimum, e.g. with a single QMainWindow, if the above does not appear<br>
to work.<br>
<br>
Pete<br>
</blockquote></div><br></div></div>It's still not working. Here's my QLabel:<br><br>class _Label(QtGui.QLabel):<br> def __init__(self, name, size, main_window):<br> QtGui.QLabel.__init__(self, name)<div class="im">
<br> # Save the size and main window.<br>
self._width, self._height = size<br> self._main_window = main_window<br> # set a minimum size to quiet Qt<br> self.setMinimumSize(100, 100)<br> self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)<br>
<br></div> def sizeHint(self):<br> sh = QtCore.QSize(100, 100)<div class="im"><br> if self._width > 0:<br> if self._width > 1:<br> w = self._width<br> else:<br>
w = self._main_window.width() * self._width<br>
sh.setWidth(int(w))<br> if self._height > 0:<br> if self._height > 1:<br> h = self._height<br> else:<br> h = self._main_window.height() * self._height<br>
sh.setHeight(int(h))<br> return sh<br><br></div>And since that didn't change the behavior at all, I took the extra QMainWindow instances out of the picture by modifying the createDockWidget() method in MainWindow:<div class="im">
<br>
<br>def createDockWidget(self, name, size):<br> dock = QtGui.QDockWidget(name, self)<br></div> child = _Label(name, size, self)<br> dock.setWidget(child)<div class="im"><br> dock.setObjectName(name)<br>
self._qt4_adjust_widget_layout(child)<br></div>
return dock<br><br>That still has no effect on the original behavior. sizeHint() is called on the _Label instances and ignored.<br><font color="#888888"><br>- John<br>
</font></div><br>