Results 1 to 9 of 9

Thread: QDateTimeEdit

  1. #1
    Join Date
    Oct 2009
    Location
    Vienna, Austria
    Posts
    57
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QDateTimeEdit

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDateTimeEdit

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    doberkofler (29th October 2009)

  4. #3
    Join Date
    Oct 2009
    Location
    Vienna, Austria
    Posts
    57
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDateTimeEdit

    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.

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDateTimeEdit

    The DateTime classes do have date restrictions.
    You can however use a normal QLineEdit, and convert the string to time/date after input.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:

    doberkofler (29th October 2009)

  7. #5
    Join Date
    Oct 2009
    Location
    Vienna, Austria
    Posts
    57
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDateTimeEdit

    Too bad: would probably be a simple a very helpful feature.
    Thank you anyway!

  8. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDateTimeEdit

    Too bad: would probably be a simple a very helpful feature.
    You can always make a custom date picker that offers that functionality!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #7
    Join Date
    Oct 2009
    Location
    Vienna, Austria
    Posts
    57
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDateTimeEdit

    This might currently exceed my abilities with Qt but could you eventually point out some documentation on this?

  10. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDateTimeEdit

    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/designe...m-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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. The following user says thank you to high_flyer for this useful post:

    doberkofler (2nd November 2009)

  12. #9
    Join Date
    Nov 2007
    Posts
    17
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTimeEdit

    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 the Display-Property, eg.

    Qt Code:
    1. QDateTimeEdit::setSpecialValueText("sorry, no entry");
    To copy to clipboard, switch view to plain text mode 

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

    Look at Tasktracker, Id 188758, unfortunately not solved

  13. The following user says thank you to montuno for this useful post:

    doberkofler (2nd November 2009)

Similar Threads

  1. Highlighting selected section on QDateTimeEdit
    By Yorma in forum Qt Programming
    Replies: 4
    Last Post: 3rd May 2013, 12:03
  2. QDateTimeEdit
    By doberkofler in forum Newbie
    Replies: 0
    Last Post: 28th October 2009, 06:28
  3. QDateTimeEdit
    By coderbob in forum Qt Programming
    Replies: 3
    Last Post: 5th January 2008, 19:54
  4. new design of QDateTimeEdit
    By Ursa in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2007, 07:30
  5. QDateTimeEdit
    By dkite in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2006, 19:12

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.