View Full Version : QTextEdit Help pls
Hi,
I am accepting a multi line text from user in a QTextEdit. I first store it in a string using toPlainText and then store it in a database. But when I retrieve the data from the database my text comes in single line. All the new line characters are lost. Can someone please help ?
Thanks a lot
wysota
6th May 2006, 20:13
Are you sure that after toPlainText() your text is still multilined? Try to write it to the console using qWarning().
When I debug I see that whereever '\n' has to come a box like character comes.
Please Help
Thanks a lot.
wysota
7th May 2006, 09:40
Check its ascii number.
Even because this works fine with a multiline text;
textEdit->setPlainText(textEdit->toPlainText());
one could come to a conclusion that the problem is on the db side.
So how does it look if you write the text fetched from the db to the console?
Hi,
I am using SQLite and I have a sqlite brower which shows the data correctly.
The problem is when I convert from QVariant to QString the new line character is lost.
Plese Help
Thanks a lot.
I am using SQLite and I have a sqlite brower which shows the data correctly.
So did you try to output the string after fetching it from the database? And even analyze it more deeply, for example output all of it's chars to see if there are line break characters at all, and if there is, what characters are they, NL/CR/?
QChar* data = str.data();
while (!data->isNull()) {
qDebug() << data->unicode();
++data;
}
The problem is when I convert from QVariant to QString the new line character is lost.
I don't think that the problem lies in QVariant at all. I highly doubt that QVariant touches the string in any way.
At least this works fine and outputs line breaks correctly:
void testSlot() {
QVariant v = toPlainText();
qDebug() << v;
setPlainText(v.toString());
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.