Results 1 to 7 of 7

Thread: clear text in QDateEdit

  1. #1
    Join Date
    Sep 2007
    Posts
    18
    Thanks
    3

    Default clear text in QDateEdit

    Hi Qt folks,

    Is there a way in Qt (4), to clear the contents of the QDateEdit???
    I mean with an empty line edit in QDateEdit....

    -James

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: clear text in QDateEdit

    See QDateEdit::clear(), inherited form QAbstractSpinBox. It clears everything except suffix and prefix.

  3. #3
    Join Date
    Sep 2007
    Posts
    18
    Thanks
    3

    Default Re: clear text in QDateEdit

    I tried it.
    But at the end, Minimum it displays the current date.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: clear text in QDateEdit

    I'm afraid it might not be that simple. As far as I remember, there are a few event handlers like showEvent() and focusInEvent() that cause internal QAbstractSpinBoxPrivate::reset() to be called. I suggest you take a look at QAbstractSpinBox/QDateTimeEdit sources for possible workarounds.
    J-P Nurmi

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

    Default Re: clear text in QDateEdit

    What do you need the empty spinbox for? Maybe there are other ways to do what you want? How about simply disabling the widget?

  6. #6
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: clear text in QDateEdit

    I wonder if there is still no way to clear the date field. As for the purpose of it, you can imagine providing an optional date field for people to fill in their birthday if they want to and use empty or "MM/DD/YYYY" instead of some arbitrary date as default. I suppose this is quite common and a little surprised that qt didn't support it.
    Thanks!

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

    Default Re: clear text in QDateEdit

    Quote Originally Posted by lisong View Post
    I suppose this is quite common and a little surprised that qt didn't support it.
    QAbstractSpinBox::specialValueText
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  4. visible text of textedit
    By regix in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2006, 09:02
  5. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 11:21

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.