Skip to content

Commit bbd8168

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR matplotlib#32221: Qt IconEngine: Use a device pixel ratio of 1 when high-DPI pixmaps are disabled
1 parent 533864a commit bbd8168

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
@@ -720,7 +720,12 @@ def pixmap(self, size, mode, state):
720720

721721
def _devicePixelRatio(self):
722722
"""Return the current device pixel ratio for the toolbar, defaulting to 1."""
723-
return (self.toolbar.devicePixelRatioF() or 1) if self.toolbar else 1
723+
use_high_dpi_pixmaps = True
724+
if hasattr(QtCore.Qt.ApplicationAttribute, "AA_UseHighDpiPixmaps"):
725+
app = QtWidgets.QApplication.instance()
726+
use_high_dpi_pixmaps = app.testAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
727+
toolbar_dpr = (self.toolbar.devicePixelRatioF() or 1) if self.toolbar else 1
728+
return toolbar_dpr if use_high_dpi_pixmaps else 1
724729

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

0 commit comments

Comments
 (0)