Skip to content

Commit 1180f3a

Browse files
committed
Force Qt5 toolbar minimum height to 48.
Even though the minimum height is set, that doesn't seem to carry over to the size hint that gets used later to determine the size of the entire window, causing the window to be a bit too short and changing the size of the canvas. Fixes #7353. Probably also fixes #7472.
1 parent e09a6f7 commit 1180f3a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,15 @@ def _init_toolbar(self):
611611
if is_pyqt5():
612612
self.setIconSize(QtCore.QSize(24, 24))
613613
self.layout().setSpacing(12)
614-
self.setMinimumHeight(48)
614+
615+
if is_pyqt5():
616+
# For some reason, self.setMinimumHeight doesn't seem to carry over to
617+
# the actual sizeHint, so override it instead in order to make the
618+
# aesthetic adjustments noted above.
619+
def sizeHint(self):
620+
size = super().sizeHint()
621+
size.setHeight(max(48, size.height()))
622+
return size
615623

616624
def edit_parameters(self):
617625
allaxes = self.canvas.figure.get_axes()

0 commit comments

Comments
 (0)