Issue
I'm using 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.
The QCalendarWidget
docs mention NoSelection
and 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()
Solution
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.