提交 b9125406 编写于 作者: 之一Yo's avatar 之一Yo

更新滑动条条样式,修复平滑滚动的 bug

上级 928e4ee2
......@@ -26,7 +26,6 @@ class MaskDialog(QDialog):
def __initWidget(self):
""" 初始化小部件 """
self.__setShadowEffect()
self.widget.setWindowOpacity(0.1)
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setGeometry(0, 0, self.parent().width(), self.parent().height())
......
......@@ -3,7 +3,7 @@ from collections import deque
from enum import Enum
from math import cos, pi
from PyQt5.QtCore import QDateTime, Qt, QTimer, QT_VERSION_STR
from PyQt5.QtCore import QDateTime, Qt, QTimer, QPoint
from PyQt5.QtGui import QWheelEvent
from PyQt5.QtWidgets import QApplication, QScrollArea
......@@ -31,10 +31,10 @@ class ScrollArea(QScrollArea):
def wheelEvent(self, e: QWheelEvent):
""" 实现平滑滚动效果 """
if self.smoothMode == SmoothMode.NO_SMOOTH or QT_VERSION_STR != '5.13.2':
if self.smoothMode == SmoothMode.NO_SMOOTH:
super().wheelEvent(e)
return
# 将当前时间点插入队尾
now = QDateTime.currentDateTime().toMSecsSinceEpoch()
self.scrollStamps.append(now)
......@@ -70,8 +70,8 @@ class ScrollArea(QScrollArea):
# 构造滚轮事件
e = QWheelEvent(self.lastWheelEvent.pos(),
self.lastWheelEvent.globalPos(),
self.lastWheelEvent.pos(),
self.lastWheelEvent.globalPos(),
QPoint(),
QPoint(0, totalDelta),
round(totalDelta),
Qt.Vertical,
self.lastWheelEvent.buttons(),
......
......@@ -12,6 +12,7 @@ class Window(QWidget):
super().__init__(parent=parent)
self.resize(300, 90)
self.hSlider = Slider(Qt.Horizontal, self)
self.hSlider.setValue(20)
self.hSlider.move(56, 30)
with open('resource/slider.qss', encoding='utf-8') as f:
self.setStyleSheet(f.read())
......
......@@ -2,7 +2,6 @@ QWidget{
background-color: white;
}
/* 水平滑动条 */
QSlider:horizontal {
height: 26px;
width: 188px;
......@@ -10,15 +9,16 @@ QSlider:horizontal {
}
QSlider::groove:horizontal {
width: 188px;
border: none;
background-color: transparent;
height: 4px;
}
QSlider::handle:horizontal {
width: 26px;
height: 26px;
border-radius: 13px;
margin-top: -11px;
margin-bottom: -11px;
background-color: rgb(0, 153, 188);
}
......@@ -34,54 +34,12 @@ QSlider::handle:horizontal:pressed {
QSlider::sub-page:horizontal {
/*已划过部分的颜色*/
background: rgb(0, 153, 187);
margin-top: 11px;
margin-bottom: 11px;
height: 4px;
border-radius: 2px;
}
QSlider::add-page:horizontal {
background-color: rgb(130, 131, 134);
margin-top: 11px;
margin-bottom: 11px;
}
/* 竖直滑动条 */
QSlider:vertical {
width: 26px;
height: 188px;
background-color: transparent;
}
QSlider::groove:vertical {
width: 26px;
border: none;
background-color: transparent;
}
QSlider::handle:vertical {
width: 26px;
height: 26px;
border-radius: 13px;
background-color: rgb(0, 153, 188);
}
QSlider::handle:vertical:hover {
background-color: rgb(72, 210, 242);
}
QSlider::handle:vertical:pressed {
background-color: rgb(0, 107, 131);
}
QSlider::add-page:vertical {
background: rgb(0, 153, 187);
margin-left: 11px;
margin-right: 11px;
}
QSlider::sub-page:vertical {
background-color: rgb(130, 131, 134);
margin-left: 11px;
margin-right: 11px;
background-color: rgb(153, 153, 153);
height: 4px;
border-radius: 2px;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册