how do get date and/time from QDateTimeEdit, QTimeEdit QDateEdit ect
to QTextEdit or QLineEdit QTableView ect.
I am new at that this and my 70 year old brain hurts.
how do get date and/time from QDateTimeEdit, QTimeEdit QDateEdit ect
to QTextEdit or QLineEdit QTableView ect.
I am new at that this and my 70 year old brain hurts.
you can get the QDate with "date()" and, after that, convert it into QString with "toString()" or use QDateTimeEdit::sectionAt() or QDateTimeEdit::sectionText(). After that, QTextEdit::setText()
many thanks for your reply Jano...
BUT i now don't know how to use them!!
my code....
QString str, str1, tr2, strdate;
QDateTime datetime;
value1 = spinBox1->value();
value2 = spinBox2->value(); // these ok
lcdnumber->display(value1 + value2);
datetime = QDateTime(); // accepts this
// strdate = QDateTime::toString; // but none of these
// QDate::toString(datetime,"dd.MM.yyyy");
// QTextEdit::setText(QDate::toString(Qt:ateFormat));
// datetime = QDateTime::toString(currentDateTime());
// textEdit->append("Current Date Time") + datetime;
//QTextEdit::acceptRichText(false); also this fails
textEdit->append("Path to file: " + lineEdit->text()); // these ok
textEdit->append("Number 1 value: " + QString::number(value1));
textEdit->append("Number 2 value: " + QString::number(value2));
void QTextEdit::setText ( const QString & text ) [slot]
perhaps it would help if i could understand what
something this means ( const QString & text ) [slot]
i need some examples
regards and thanks
Brian
after much got these to work...
QDateTime datetime = QDateTime::currentDateTime(); //works ok
textEdit->append("date time is: " + datetime.toString()); // "
this also works...
// QString tr3 = datetime.toString(); // also works
// textEdit->append("date is: " + tr3); // "
both give me the required result
NOW how do i get QDateTimeEdit settings to QTextEdit??????????
I know what Qt functions to use but HOWWW??
QtCreator is the ants pants![]()
I'm not sure what you mean by this. Which settings? How do they make sense in a text edit control?
You already have the QDate expressed as a string, which you can stick into the text edit. You can tweak to format of the string with parameters to the toString method.
If you want to embed a QDateTimeEdit control into the flow of text in a text edit then I don't think I can help.
I don't really understand where is your problem.
I think you want to have something like:
Qt Code:
//we already have a QTextEdit called "textEdit" //we want to have the hole current date textEdit.setText(strDate); //we prefer to have only the day textEdit.clear();//clear :P int iDay = dDate.day(); //get the day textEdit.setText(strDay);To copy to clipboard, switch view to plain text mode
Hope it helps... if you have any answer or you were asking another issue just ask again![]()
thanks for your reply
what i want to do is put the DateTime shown in the
QDateTimeEdit into the QTextEdit
regards
Briang
Ok... is this?
Qt Code:
//we already have a QDateTimeEdit called "myDateTimeEdit" myDateTimeEdit.setDateTime(datetime);To copy to clipboard, switch view to plain text mode
the point I don't understand is a "QDateTimeEdit into a QTextEdit"
briang (16th October 2009)
This might be what you are after:
Qt Code:
// get the value from the edit // format with the same format as the date time edit // do stuff with the time/date string ...To copy to clipboard, switch view to plain text mode
briang (16th October 2009)
G'day Jano and Chris
YES that is exactly what i was after
QDateTime datetime1 = QDateTime::currentDateTime(); //sets QDateTimeEdit to today.
dateTimeEdit->setDateTime(datetime1);
QDateTime datetime2 = dateTimeEdit->dateTime(); //prints QDateTimeEdit to textEdit
QString timeDateString = datetime2.toString(dateTimeEdit->displayFormat());
textEdit->append(timeDateString); |
Chris you show a full stop here but when i press fullstop i get this automatically.
i did not know this to till now.
At the moment i am just trying out how the various widgets interconnect.
am now going to attack QTable ect.
using Qt Creator 1.2.1 Qt4.5.2 (64bit) on kde4.3.1
THANK YOU THANK YOU both
Qt Creator is the ants pants.
regards to you both
Brian.
Bookmarks