Results 1 to 3 of 3

Thread: Two QDate issues

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Two QDate issues

    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! 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Two QDate issues

    Quote Originally Posted by GreyGeek
    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! 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?
    Last edited by wysota; 7th March 2006 at 19:56.

  3. #3
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Two QDate issues

    Quote Originally Posted by wysota
    ... 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!

Similar Threads

  1. QDate class extension
    By Carlton in forum Newbie
    Replies: 1
    Last Post: 22nd February 2009, 07:33
  2. QDate an locale setting
    By Boron in forum Qt Programming
    Replies: 5
    Last Post: 10th October 2008, 15:15
  3. Problems with QDate
    By cyberboy in forum Qt Programming
    Replies: 4
    Last Post: 25th May 2008, 21:17
  4. Converting VC++ qreal to QDate
    By Krish_ng in forum Qt Programming
    Replies: 13
    Last Post: 12th January 2008, 19:23
  5. Issues updating to QMdiArea
    By fnmblot in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2007, 18:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.