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
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,
_
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.
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,
_