Results 1 to 4 of 4

Thread: How to Populate QDateEdit Stored in QString again into a QDateEdit

  1. #1
    Join Date
    Jan 2017
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default How to Populate QDateEdit Stored in QString again into a QDateEdit

    I have 2 QDateEdit which are Date_dob and Date_doj.

    I am storing the value using a Qstring shown below.

    QString str_dob(ui->DATE_dob->text());
    QString str_doj(ui->DATE_doj->text());

    Now i want to populate the same into ui->Date_dob and ui->Date_doj (after some editing event takes place). I have used ,

    ui->DATE_dob->setText(s.at(2));
    ui->DATE_doj->setText(s.at(5)); //where s is a string having data

    but the data doesnt polpulate.

    Any kind of suggestion will be extremely appreicated.
    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Populate QDateEdit Stored in QString again into a QDateEdit

    You might have to parse the string into QDate object and pass that to the widget.
    See QDate::fromString(), but also consider storing the dates as dates.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2017
    Posts
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Populate QDateEdit Stored in QString again into a QDateEdit

    I will try this for sure. But problem is i m using txt file. and all read, write, edit and delete logic is done with QStrings and indexing which then populates in QTableWidget. This might invovle alot of changes throughout the code.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to Populate QDateEdit Stored in QString again into a QDateEdit

    Well in this case just format the date in a specific way and then use the same format for parsing it back.

    I.e. QDate::toString() and QDate::fromString() with the same format.

    Cheers,
    _

Similar Threads

  1. QDateEdit clear()
    By Henry Blue Heeler in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2014, 00:24
  2. 2 QDateEdit with 1 QCalendarWidget ?
    By ouekah in forum Newbie
    Replies: 4
    Last Post: 26th April 2010, 10:24
  3. Null for QDateEdit
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2009, 22:54
  4. Clearing QDateEdit
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2006, 22:19
  5. Subclassing QDateEdit
    By jamadagni in forum Qt Programming
    Replies: 6
    Last Post: 4th February 2006, 14:26

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.