zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.61k stars 541 forks source link

CalendarPicker如果设置了日期后,这个日期就无法再选中 #282

Closed Cheukfung closed 1 year ago

Cheukfung commented 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_()
Cheukfung commented 1 year ago

应该是calendarview里面的_onDayItemClicked事件中,没有给calendarview自身的date赋值导致的。