PDA

View Full Version : PyQt --How to wire up the signals from QDateEdit to slots on QCalendarWidget



PY_Skywalker
28th October 2016, 16:00
Hello All

I am trying to "Synchronise" the QCalendarWidget and QDateEdit widgets. I have managed to synchonise other widgets like sliders and tool bars by using the following statement self.ui.horizontalScrollBar.valueChanged.connect(s elf.scrollhorizontal)

I have managed to use signals and slots to get the QDateEdit widget updated when selecting the date in QCalendarWidget as per the following

QtCore.QObject.connect(self.ui.calendarWidget, QtCore.SIGNAL('selectionChanged()'), self.dispdate)


def dispdate(self):
self.ui.dateEdit.setDate(self.ui.calendarWidget.se lectedDate())

I do not seem to do the reverse i.e. wire up the QCalendarWidget so that when I change the QDateEdit value the QCalendarWidget gets updated

I have tried the following

QtCore.QObject.connect((self.ui.dateEdit), QtCore.SIGNAL('editingFinished()'),self.calwupd)

def calwupd(self):
self.ui.calendarWidget.setSelectedDate(self.ui.dat eEdit.Date())

Environment Details:
Windows 8.1
Python 3.4
PyQt 4

Your help would be much appreciated.

Many Thanks

James

anda_skoa
29th October 2016, 08:15
You could directly connect the QDateEdit's dateChanged() signal to the QCalendarWidget's setSelectedDate() slot.

Cheers,
_