Capture date from Qdateedit

Asked

Viewed 390 times

2

I need to pick a date QDateEdit. I did the designer using Qt Designer, in properties activated calendarPopup and the displayFormat for dd/MM/yyyy.

I want to capture this date to insert in a query. I have 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?

1 answer

1


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

data = self.dlg.data.date().toPyDate()
  • Man, I spent a lot of time looking at the Qdateedit documentation and I didn’t see it and you answered me in a matter of minutes.

  • Thanks, bro. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.