On Mon, Oct 11, 2010 at 2:21 PM, Hans-Peter Jansen <[email protected]> wrote:
> On Monday 11 October 2010, 17:58:35 John Wiggins wrote: > > On Mon, Oct 11, 2010 at 10:33 AM, Hans-Peter Jansen <[email protected]> > wrote: > > > On Monday 11 October 2010, 16:17:21 John Wiggins wrote: > > > > Hello, > > > > > > > > I'm laying out part of the UI for my app using a QMainWindow with > > > > no central widget and 4 dock widgets. I'd like the dock widgets > > > > to be sized proportionally to each other but they seem to ignore > > > > the value returned by sizeHint(). Am I missing something? > > You could try to subclass the QLabels and implement sizeHint for them, > leaving _ViewContainer alone (size wise).. Let us know, if that helps. > > Since you have QMainWindows in each of your dock widgets, the outcome is > still hard to predict. You may want to reduce your example to the bare > minimum, e.g. with a single QMainWindow, if the above does not appear > to work. > > Pete > It's still not working. Here's my QLabel: class _Label(QtGui.QLabel): def __init__(self, name, size, main_window): QtGui.QLabel.__init__(self, name) # Save the size and main window. self._width, self._height = size self._main_window = main_window # set a minimum size to quiet Qt self.setMinimumSize(100, 100) self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) def sizeHint(self): sh = QtCore.QSize(100, 100) if self._width > 0: if self._width > 1: w = self._width else: w = self._main_window.width() * self._width sh.setWidth(int(w)) if self._height > 0: if self._height > 1: h = self._height else: h = self._main_window.height() * self._height sh.setHeight(int(h)) return sh 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: def createDockWidget(self, name, size): dock = QtGui.QDockWidget(name, self) child = _Label(name, size, self) dock.setWidget(child) dock.setObjectName(name) self._qt4_adjust_widget_layout(child) return dock That still has no effect on the original behavior. sizeHint() is called on the _Label instances and ignored. - John
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
