Setting a minimum QDate with todays date

2.5k Views Asked by At

I'm trying to set the minimum date for a QDate box to todays date. I keep getting a syntax. I have set the format which works fine, but the minimum date won't work.

    self.ui.CreateStuDOB.setDisplayFormat("dd.MM.yyyy")
    self.ui.CreateStuDOB.setMinimumDate(QDate::currentDate())

Returned error

self.ui.CreateStuDOB.setMinimumDate(QDate::currentDate()) ^ SyntaxError: invalid syntax

Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

Solved.

Firstly I used the correct Python syntax instead of the C++ syntax as pointed out by ekhumoro.

self.ui.CreateStuDOB.setMinimumDate(QDate.currentDate())

Then I correctly imported QDate using:

from PyQt4.QtCore import *