MrPython
MrPython

Reputation: 268

Setting a minimum QDate with todays date

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

Upvotes: 0

Views: 2683

Answers (1)

MrPython
MrPython

Reputation: 268

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 *

Upvotes: 3

Related Questions