QCalendarWidget in PyQt to find a single date that a user clicks on from a pop-up calendar. I’d like them to be able to select a range of dates- for example, the 12th to the 17th of November instead of just the 12th.
QCalendarWidget docs mention
SingleSelection. How can I implement a multiple selection?
Here is the code I have now:
def selectDates(self): self.dateWindow = QWidget() self.cal = QCalendarWidget(self) self.cal.clicked[QtCore.QDate].connect(self.showDate) self.hbox = QHBoxLayout() self.hbox.addWidget(self.cal) self.dateWindow.setLayout(self.hbox) self.dateWindow.setGeometry(300, 300, 350, 300) self.dateWindow.setWindowTitle('Calendar') self.dateWindow.show() def showDate(self): print "Date picked: ", self.cal.selectedDate()
I don’t think that this is possible.
I’m sure you already considered the fact of adding two calendar widgets or dateEdit widgets (one for the first date of the range and one for the last).
But unless you think you can develop a overriden class, you really should think on that possibility.
Answered By – jonathan.hepp
Answer Checked By – Willingham (BugsFixing Volunteer)