PDA

View Full Version : clear text in QDateEdit



dyams
15th October 2007, 12:20
Hi Qt folks,

Is there a way in Qt (4), to clear the contents of the QDateEdit???
I mean with an empty line edit in QDateEdit....

-James

marcel
15th October 2007, 12:23
See QDateEdit::clear(), inherited form QAbstractSpinBox. It clears everything except suffix and prefix.

dyams
25th October 2007, 06:05
I tried it.
But at the end, Minimum it displays the current date.

jpn
25th October 2007, 08:13
I'm afraid it might not be that simple. As far as I remember, there are a few event handlers like showEvent() and focusInEvent() that cause internal QAbstractSpinBoxPrivate::reset() to be called. I suggest you take a look at QAbstractSpinBox/QDateTimeEdit sources for possible workarounds.

wysota
25th October 2007, 08:22
What do you need the empty spinbox for? Maybe there are other ways to do what you want? How about simply disabling the widget?

lisong
31st August 2010, 22:19
I wonder if there is still no way to clear the date field. As for the purpose of it, you can imagine providing an optional date field for people to fill in their birthday if they want to and use empty or "MM/DD/YYYY" instead of some arbitrary date as default. I suppose this is quite common and a little surprised that qt didn't support it.:(
Thanks!

wysota
31st August 2010, 22:30
I suppose this is quite common and a little surprised that qt didn't support it.:(
QAbstractSpinBox::specialValueText