重写mousePressEvent
和mouseReleaseEvent
捕获鼠标按下和抬起事件,使用QTimer
计时,模拟长按的效果
重点关注LongClickButton,关键逻辑都在其中,
import sys
from PySide2.QtWidgets import QWidget, QApplication, QPushButton
from PySide2.QtCore import QTimer
class LongClickDemo(QWidget):
def __init__(self, parent=None):
super(