Solved QDateEdit Is it possible for user to start typing date without auto completing?
-
I have a QDateEdit widget where the user can type in a date. The widget also has a calendar popup where they can select a date. The QDateEdit widget has 3 sections: month, date, year.
Is it possible for the user to start typing a date without the rest of the date auto-completing? Currently, if the user types any value, the rest of the date auto-completes to the first of the month. The date is then validated each time the user switches between month, day, and year sections. Is it possible to not validate the date until the widget loses focus?
I am new to developing with QT so please bear with me. Thanks!
-
From the sounds of what you want you probably don't want to use a QDateEdit. I would instead use a QLineEdit with an input mask. Then no date will be autocompleted and you can verify it yourself using a QDate when it loses focus.
To answer your question though, no you can't change either of those things without overriding the classes and doing it yourself. There is no built in way to the class.
-
@psigil
I agree with what @ambershark has said aboutQDateEdit
widget.For the record: I (my users) could not cope with the way
QDateEdit
validates as it goes along, and does not allow the date to be left empty. I ended up rolling my own "composite widget": aQLineEdit
plus a "..." button to the right of it which invokes a (modal) dialog containing aQCalendarWidget
that copies the selected date back into theQLineEdit
.