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

设置滚动代理的滚动模式为逐像素

上级 d654dc35
......@@ -3,7 +3,7 @@ from PyQt5.QtCore import (QEvent, QEasingCurve, Qt, pyqtSignal, QPropertyAnimati
QTimer, QPoint, QObject)
from PyQt5.QtGui import QPainter, QColor, QMouseEvent
from PyQt5.QtWidgets import (QWidget, QToolButton, QAbstractScrollArea, QGraphicsOpacityEffect,
QHBoxLayout, QVBoxLayout, QApplication)
QHBoxLayout, QVBoxLayout, QApplication, QAbstractItemView)
from ...common.icon import FluentIcon
from ...common.style_sheet import isDarkTheme
......@@ -485,6 +485,10 @@ class SmoothScrollDelegate(QObject):
self.verticalSmoothScroll = SmoothScroll(parent, Qt.Vertical)
self.horizonSmoothScroll = SmoothScroll(parent, Qt.Horizontal)
if isinstance(parent, QAbstractItemView):
parent.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
parent.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
parent.viewport().installEventFilter(self)
parent.setVerticalScrollBarPolicy = self.setVerticalScrollBarPolicy
parent.setHorizontalScrollBarPolicy = self.setHorizontalScrollBarPolicy
......
......@@ -130,15 +130,11 @@ class TableBase:
# set style sheet
FluentStyleSheet.TABLE_VIEW.apply(self)
FluentStyleSheet.TABLE_VIEW.apply(self.verticalScrollBar())
FluentStyleSheet.TABLE_VIEW.apply(self.horizontalScrollBar())
self.setShowGrid(False)
self.setMouseTracking(True)
self.setItemDelegate(self.delegate)
self.setSelectionBehavior(TableWidget.SelectRows)
self.setVerticalScrollMode(QTableView.ScrollPerPixel)
self.setHorizontalScrollMode(QTableView.ScrollPerPixel)
self.entered.connect(lambda i: self.setHoverRow(i.row()))
self.pressed.connect(lambda i: self.setPressedRow(i.row()))
......
......@@ -45,15 +45,11 @@ class TreeViewBase:
def __init__(self, *args, **kwargs):
self.scrollDelagate = SmoothScrollDelegate(self)
self.setHorizontalScrollMode(QTreeView.ScrollPerPixel)
self.setVerticalScrollMode(QTreeView.ScrollPerPixel)
self.setItemDelegate(TreeItemDelegate(self))
self.setIconSize(QSize(16, 16))
FluentStyleSheet.TREE_VIEW.apply(self)
FluentStyleSheet.TREE_VIEW.apply(self.verticalScrollBar())
FluentStyleSheet.TREE_VIEW.apply(self.horizontalScrollBar())
def drawBranches(self, painter, rect, index):
rect.moveLeft(15)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册