PDA

View Full Version : QDateTimeEdit



doberkofler
29th October 2009, 16:20
In date range selections it is quite usual to using an empty date when the lower and/or upper limit of the range is open.
Is there a way to allow entering and displaying empty (NULL) dates in QDateTimeEdit and it's derived classes?
I did not find anything so I was wondering what the next best way to solve this would be?
Thank you in advance.
Reply With Quote

high_flyer
29th October 2009, 17:44
In date range selections it is quite usual to using an empty date when the lower and/or upper limit of the range is open.
Can you give an example?

You can set time 00:00:00.
You cant set year 0, but you can set some minimumyear that will be used to indicate "NULL" year.

doberkofler
29th October 2009, 17:55
Example:

1) From "01 Jan 2009" to "31 Dec 2009" -> this would be a "normal" date interval
2) From "" to "31 Dec 2009" -> this would not limit the begin of the date interval
3) From "01 Jan 2009" to "" -> this would not limit the end of the date interval
4) From "" to "" -> this would not limit the date at all

I just do not see a way to define an empty date that would mean no date restriction.

high_flyer
29th October 2009, 18:03
The DateTime classes do have date restrictions.
You can however use a normal QLineEdit, and convert the string to time/date after input.

doberkofler
29th October 2009, 18:18
Too bad: would probably be a simple a very helpful feature.
Thank you anyway!

high_flyer
30th October 2009, 13:41
Too bad: would probably be a simple a very helpful feature.
You can always make a custom date picker that offers that functionality! ;)

doberkofler
30th October 2009, 15:08
This might currently exceed my abilities with Qt but could you eventually point out some documentation on this?

high_flyer
2nd November 2009, 13:32
Documentation on what? on how to created custom widgets?
It nothing more then C++ sub classing.
You can start by looking at this:
http://doc.trolltech.com/4.4/designer-creating-custom-widgets.html
which aims at designer plugins, which you may or may not want, but you can see there how to go about creating custom widgets.

montuno
2nd November 2009, 15:10
Is there a way to allow entering and displaying empty (NULL) dates in QDateTimeEdit and it's derived classes?

Set (in your special cases) with QAbstractSpinBox::specialValueText (http://qt.nokia.com/doc/4.5/qabstractspinbox.html#specialValueText-prop) the Display-Property, eg.


QDateTimeEdit::setSpecialValueText("sorry, no entry");

It's maybe not the best way I think, but it works.

Look at Tasktracker, Id 188758 (http://qt.nokia.com/developer/task-tracker/index_html?method=entry&id=188758), unfortunately not solved