PyQt get date from the user

前端 未结 1 1814
温柔的废话
温柔的废话 2021-01-19 11:09

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 sav

1条回答
  •  无人共我
    2021-01-19 11:14

    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"

    0 讨论(0)
提交回复
热议问题