Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt get date from the user

I built simple widget in Qt Designer with a button and a QDateEdit. The user will enter the date into the QDateEdit and then when he presses the button, the date will be saved to a variable.

How can I do it?

like image 674
pol Avatar asked Dec 01 '22 07:12

pol


1 Answers

You can make it simply:

var_name = self.dateEdit.date()

This will get you a variable in QDate format. If you need it in a format which would be easier to work with then you should use this:

temp_var = self.dateEdit.date() 
var_name = temp_var.toPyDate()

The first one gives you: "PyQt4.QtCore.QDate(2011, 11, 8)"

While the second returns: "2011-11-08"

like image 179
jonathan.hepp Avatar answered Dec 04 '22 04:12

jonathan.hepp