I would like to get the date from the users from selecting in the dateEdit form or CalendarPopup after they click the pushButton. Below is my code of setting widget.
self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
self.dateEdit.setGeometry(QtCore.QRect(139, 250, 151, 22))
self.dateEdit.setObjectName("dateEdit")
self.dateEdit.setDateTime(QtCore.QDateTime.currentDateTime())
self.dateEdit.setMaximumDate(QtCore.QDate(7999, 12, 28))
self.dateEdit.setMaximumTime(QtCore.QTime(23, 59, 59))
self.dateEdit.setDisplayFormat("dd/MM/yyyy")
self.dateEdit.setCalendarPopup(True)
and when push the button, the date (dd/MM/yyyy) will display as they filled in.
self.pushButton.clicked.connect(self.running)
def running(self):
dfrom = self.dateEdit.text()
print('from' & dfrom)
if I add 'print(dfrom)' there is no error showing up, but the GUI will close itself and not display the result. Dont know if it is related to each other. Please tell me where I did it wrong.