Capturing date from QDateEdit

1

I need to get the date of a QDateEdit . I made the designer using Qt Designer, in properties enabled calendarPopup and displayFormat to dd/MM/yyyy .

I want to capture this date to insert into a query. I've tried using the following codes:

data = self.dlg.data.currentDate() # apresenta um erro 'QDateEdit' object has no attribute 'currentDate'

I've tried another way:

data = self.dlg.data.date() # Até pego a data, mas no formato estranho veja: "PyQt4.QtCore.QDate(2016, 9, 14)"

I also used:

data = self.dlg.data.currentSection() # traz um número 512, mas não no formato dd/MM/yyyy.

What is the solution?

    
asked by anonymous 25.10.2016 / 01:57

1 answer

1

To return the date in string use the method qdate#toPyDate :

data = self.dlg.data.date().toPyDate()
    
25.10.2016 / 02:12