Re: [PyQt] QDockWidget sizing behavior
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? Without looking deeper into your code, there's something you should note (from the Qt QDockWidget documentation): Appearance [...] A QDockWidget acts as a wrapper for its child widget, set with setWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. Hth, Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QDockWidget sizing behavior
On Mon, Oct 11, 2010 at 10:33 AM, Hans-Peter Jansen h...@urpla.net 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? Without looking deeper into your code, there's something you should note (from the Qt QDockWidget documentation): Appearance [...] A QDockWidget acts as a wrapper for its child widget, set with setWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. Hth, Pete Hello Pete, I've done all those things except setting a maximum size. Also, I didn't post this useful info before: python - 2.5.4 qt - 4.5.4 pyqt - 4.6.2 - John ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QDockWidget sizing behavior
On Monday 11 October 2010, 17:58:35 John Wiggins wrote: On Mon, Oct 11, 2010 at 10:33 AM, Hans-Peter Jansen h...@urpla.net 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 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QDockWidget sizing behavior
On Mon, Oct 11, 2010 at 2:21 PM, Hans-Peter Jansen h...@urpla.net wrote: On Monday 11 October 2010, 17:58:35 John Wiggins wrote: On Mon, Oct 11, 2010 at 10:33 AM, Hans-Peter Jansen h...@urpla.net 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 listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QDockWidget sizing behavior
Wow, I feel daft now :) Thanks for the sharp gaze Baz. I'll look through the more complicated code that this example is based on and see if the problem was really this dumb... - John On Mon, Oct 11, 2010 at 6:04 PM, Baz Walter baz...@ftml.net wrote: On 11/10/10 15:17, 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? - John Here's a concrete example illustrating my problem: [snip] def createDockWindows(self): dock1 = self.createDockWidget(Dock1, (0.5, 0.75)) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock1) dock2 = self.createDockWidget(Dock2, (0.5, 0.75)) self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock2) dock3 = self.createDockWidget(Dock3, (0.5, 0.25)) self.splitDockWidget(dock2, dock3, QtCore.Qt.Horizontal) dock4 = self.createDockWidget(Dock4, (0.5, 0.25)) self.splitDockWidget(dock1, dock4, QtCore.Qt.Horizontal) this makes no sense: how can the top dock area and the bottom dock area *both* have 75% of the height? change dock2 to (0.5, 0.25), and dock4 to (0.5, 0.75), and it should work correctly (well, it does for me using qt4.7, anyway). (nb: and don't forget to disable your restoreLayout method before trying :) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt