
Originally Posted by
munna
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;
}
QChar* data = str.data();
while (!data->isNull()) {
qDebug() << data->unicode();
++data;
}
To copy to clipboard, switch view to plain text mode

Originally Posted by
munna
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() {
qDebug() << v;
setPlainText(v.toString());
}
void testSlot() {
QVariant v = toPlainText();
qDebug() << v;
setPlainText(v.toString());
}
To copy to clipboard, switch view to plain text mode
Bookmarks