PyQt5-QCheckBox-开关按钮
效果预览
实现代码
from PyQt5.QtWidgets import QCheckBox, QApplication, QWidget, QVBoxLayout
from PyQt5.QtCore import Qt, QRect, QPropertyAnimation, QEasingCurve, pyqtProperty
from PyQt5.QtGui import QPainter, QColor, QPen, QFont
class CompactSwitchCheckbox(QCheckBox):
def __init__(self, parent=None):
super().__init__(parent)
# 调整控件的整体尺寸为 60x30
self.setFixedSize(60, 30)