Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to set an empty(null) date in QDateEdit?



  • The last answer in search is about five years ago.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Nothing as changed. There's no empty date, either you have a valid or an invalid date. If you try to set a null date, it won't change anything.



  • Thank you.
    It's pretty terrible )


  • Lifetime Qt Champion

    What is your use case ?



  • I make a form with row search, using date-range (two date edits for each range). I can use wittingly large range, but it not comfortable for user (and date pickers actually not usefull). It will to confuse user. But there are high requirements to useability.
    I'm sorry for my english.



  • And the second case: We have a form with client birhtday (required parameter). Operator (user) sees an empty field - he will not forget to fill it (and it simle to check, if he forgot). But date 01.01.2000 (or any other) looks good (and we only can use a signal "dateChanged" to get to know there was a change or not). But even this does not guarantee the accuracy, because user may not change a date (a date may coincide with a correct), and we will not take a signal.


  • Lifetime Qt Champion

    For the raw search you can use a QCheckBox to enable/disable the date range from the earch.

    As for the birthdate, if you use the current date you are not likely to have someone of that age using your application.


Log in to reply