Closed Cheukfung closed 1 year ago
当用代码picker.setDate()为calendar picker设置日期如2023-06-16后,点击控件上其他日期后如6月17日,再点击16日也无法切换到6月16日。
复现代码:
# coding:utf-8 import sys from time import time from PyQt5.QtCore import Qt, QDate from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout from qfluentwidgets import CalendarPicker class Demo(QWidget): def __init__(self): super().__init__() self.setStyleSheet('Demo{background: white}') self.picker = CalendarPicker(self) self.picker.dateChanged.connect(print) # set date self.picker.setDate(QDate(2023, 5, 30)) self.hBoxLayout = QHBoxLayout(self) self.hBoxLayout.addWidget(self.picker, 0, Qt.AlignCenter) self.resize(500, 500) if __name__ == '__main__': QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) app = QApplication(sys.argv) t0 = time() w = Demo() t1 = time() print('耗时:', t1-t0) w.show() app.exec_()
应该是calendarview里面的_onDayItemClicked事件中,没有给calendarview自身的date赋值导致的。
当用代码picker.setDate()为calendar picker设置日期如2023-06-16后,点击控件上其他日期后如6月17日,再点击16日也无法切换到6月16日。
复现代码: