PDA

View Full Version : Two QDate issues



GreyGeek
7th March 2006, 16:51
Folks,
1) The app requirements changed from using just the year to using mm/dd/year. I replaced the int year field with a date field and used the QDate control on my appliation. Not suprisingly, it seems some tax payers don't pay attention to the mm and dd part of the "Birthdate: __/__/____" line.

So now the clerks are requesting that they be able to leave the MM and DD blank! :eek: I've check the documents and played with the control but I can find no properties, methods or backdoor tricks that will allow a date of "00/00/1940", for example. Does anyone know if/how that is possible? The last thing I want to do is replace the date field with three integer fields.

2) I can programmatically change the focus to a QDate control, but when I do that all three sections of the control (mm/dd/yyyy) are selected and highlighted. When the user begins typing the highlighting disappears and the control doesn't respond to any attempts to replace any sections until a section of the control (mm or dd or yyyy) is selected and highlighted separately. When they tab into the field during normal data editing the mm section is highlighted and selected automatically, allowing changes or continued tabbing through. I have a workaround which requires that they "SHIFT+TAB" to the previous field and then TAB back into the date field. Again, after consulting the docs and the QFocus stuff I find no property or method which allows me to programmatically select just the month section of a QDate field. Is there?

TIA.

wysota
7th March 2006, 19:53
Folks,
1) The app requirements changed from using just the year to using mm/dd/year. I replaced the int year field with a date field and used the QDate control on my appliation. Not suprisingly, it seems some tax payers don't pay attention to the mm and dd part of the "Birthdate: __/__/____" line.

So now the clerks are requesting that they be able to leave the MM and DD blank! :eek: I've check the documents and played with the control but I can find no properties, methods or backdoor tricks that will allow a date of "00/00/1940", for example. Does anyone know if/how that is possible? The last thing I want to do is replace the date field with three integer fields.


No, not really. This is an invalid date. You have to provide a day and a month for it to become valid. You can hack it with using a QString and checking if the date is a valid QDate. If not, just retrieve the year from the string, otherwise retrieve a whole date.


2) I can programmatically change the focus to a QDate control, but when I do that all three sections of the control (mm/dd/yyyy) are selected and highlighted. When the user begins typing the highlighting disappears and the control doesn't respond to any attempts to replace any sections until a section of the control (mm or dd or yyyy) is selected and highlighted separately. When they tab into the field during normal data editing the mm section is highlighted and selected automatically, allowing changes or continued tabbing through. I have a workaround which requires that they "SHIFT+TAB" to the previous field and then TAB back into the date field. Again, after consulting the docs and the QFocus stuff I find no property or method which allows me to programmatically select just the month section of a QDate field. Is there?

What about catching key events (probably using event() as you need to catch the tab key) and using QDateTimeEdit::setCurrentSection to set focus to a section of your choice?

GreyGeek
8th March 2006, 02:09
... snip...

What about catching key events (probably using event() as you need to catch the tab key) and using QDateTimeEdit::setCurrentSection to set focus to a section of your choice?
mmm... QDateEditTime... that's a intesting idea.

I was looking for something like setCurrentSection in QDate, because the time component of of QDateTime isn't needed ... just mm/dd/yyyy. I quess I could use a format string to eliminate the time component. Thanks, wysota!