Skip to content

Commit c166b33

Browse files
authored
Merge pull request #32221 from iccir/fix-qt5-toolbar-icons
Qt IconEngine: Use a device pixel ratio of 1 when high-DPI pixmaps are disabled
2 parents 855008e + 1f60bd9 commit c166b33

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/matplotlib/backends/backend_qt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,12 @@ def pixmap(self, size, mode, state):
723723

724724
def _devicePixelRatio(self):
725725
"""Return the current device pixel ratio for the toolbar, defaulting to 1."""
726-
return (self.toolbar.devicePixelRatioF() or 1) if self.toolbar else 1
726+
use_high_dpi_pixmaps = True
727+
if hasattr(QtCore.Qt.ApplicationAttribute, "AA_UseHighDpiPixmaps"):
728+
app = QtWidgets.QApplication.instance()
729+
use_high_dpi_pixmaps = app.testAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
730+
toolbar_dpr = (self.toolbar.devicePixelRatioF() or 1) if self.toolbar else 1
731+
return toolbar_dpr if use_high_dpi_pixmaps else 1
727732

728733
def _create_pixmap_from_svg(self, svg_path, size):
729734
"""Create a pixmap from SVG with proper scaling and dark mode support."""

0 commit comments

Comments
 (0)