35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
|
|
# coding:utf-8
|
||
|
|
import sys
|
||
|
|
from PySide6.QtCore import QEasingCurve, Qt
|
||
|
|
from PySide6.QtGui import QPixmap
|
||
|
|
from PySide6.QtWidgets import QApplication
|
||
|
|
from qfluentwidgets import SmoothScrollArea, PixmapLabel, ScrollBarHandleDisplayMode
|
||
|
|
|
||
|
|
|
||
|
|
class Demo(SmoothScrollArea):
|
||
|
|
|
||
|
|
def __init__(self):
|
||
|
|
super().__init__()
|
||
|
|
self.label = PixmapLabel(self)
|
||
|
|
self.label.setPixmap(QPixmap("resource/shoko.jpg"))
|
||
|
|
|
||
|
|
# display the handle only when mouse hover the scroll bar region
|
||
|
|
# self.delegate.vScrollBar.setHandleDisplayMode(ScrollBarHandleDisplayMode.ON_HOVER)
|
||
|
|
|
||
|
|
# customize scroll animation
|
||
|
|
self.setScrollAnimation(Qt.Vertical, 500, QEasingCurve.OutQuint)
|
||
|
|
self.setScrollAnimation(Qt.Horizontal, 500, QEasingCurve.OutQuint)
|
||
|
|
|
||
|
|
self.horizontalScrollBar().setValue(1900)
|
||
|
|
self.setWidget(self.label)
|
||
|
|
self.resize(960, 640)
|
||
|
|
|
||
|
|
with open('resource/demo.qss', encoding='utf-8') as f:
|
||
|
|
self.setStyleSheet(f.read())
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
app = QApplication(sys.argv)
|
||
|
|
w = Demo()
|
||
|
|
w.show()
|
||
|
|
app.exec()
|