diff --git a/examples/demo_widget.py b/examples/demo_widget.py index c442e7b..6ae80ee 100644 --- a/examples/demo_widget.py +++ b/examples/demo_widget.py @@ -106,8 +106,6 @@ if __name__ == "__main__": import sys from pathlib import Path - QtW.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) - dest = Path("screenshots") dest.mkdir(exist_ok=True) diff --git a/qtrangeslider/_qrangeslider.py b/qtrangeslider/_qrangeslider.py index e757267..0582345 100644 --- a/qtrangeslider/_qrangeslider.py +++ b/qtrangeslider/_qrangeslider.py @@ -199,12 +199,10 @@ class QRangeSlider(QSlider): return opt def _getBarColor(self): - return self._style.brush_active or QtGui.QColor() + return self._style.brush_active or "" def _setBarColor(self, color): - from ._style import parse_color - - self._style.brush_active = parse_color(color) + self._style.brush_active = color barColor = Property(str, _getBarColor, _setBarColor) diff --git a/qtrangeslider/_style.py b/qtrangeslider/_style.py index c7fb4dc..6b08db0 100644 --- a/qtrangeslider/_style.py +++ b/qtrangeslider/_style.py @@ -3,6 +3,7 @@ import re from dataclasses import dataclass, replace from typing import TYPE_CHECKING, Union +from .qtcompat import PYQT_VERSION from .qtcompat.QtCore import Qt from .qtcompat.QtGui import ( QColor, @@ -77,9 +78,9 @@ class RangeSliderStyle: off += self.h_offset or SYSTEM_STYLE.h_offset or 0 else: off += self.v_offset or SYSTEM_STYLE.v_offset or 0 - if tp & QSlider.TicksAbove: + if tp == QSlider.TicksAbove: off += self.tick_offset or SYSTEM_STYLE.tick_offset - elif tp & QSlider.TicksBelow: + elif tp == QSlider.TicksBelow: off -= self.tick_offset or SYSTEM_STYLE.tick_offset return off @@ -119,6 +120,9 @@ CATALINA_STYLE = replace( tick_offset=4, ) +if PYQT_VERSION and int(PYQT_VERSION.split(".")[0]) == 6: + CATALINA_STYLE = replace(CATALINA_STYLE, tick_offset=2) + BIG_SUR_STYLE = replace( CATALINA_STYLE, brush_active="#0A81FE", @@ -131,6 +135,9 @@ BIG_SUR_STYLE = replace( tick_bar_alpha=0.2, ) +if PYQT_VERSION and int(PYQT_VERSION.split(".")[0]) == 6: + BIG_SUR_STYLE = replace(BIG_SUR_STYLE, tick_offset=-3) + WINDOWS_STYLE = replace( BASE_STYLE, brush_active="#550179D7", diff --git a/qtrangeslider/qtcompat/QtWidgets.py b/qtrangeslider/qtcompat/QtWidgets.py index f71e56b..1f0e3bd 100644 --- a/qtrangeslider/qtcompat/QtWidgets.py +++ b/qtrangeslider/qtcompat/QtWidgets.py @@ -22,7 +22,7 @@ elif PYQT6: # backwards compat with PyQt5 # namespace moves: - for cls in (QStyle, QSlider): + for cls in (QStyle, QSlider, QSizePolicy): for attr in dir(cls): if not attr[0].isupper(): continue