PDA

View Full Version : Saving QTextEdit



lixo1
1st March 2009, 11:55
Hi everybody,

I found a little strange thing on the Rich Text example (qtdemo)
I tried to save a simple text with line spaces and greek symbols in HTML format, but the output doesn't contains any line spaces (see attachment), however if I save using plainText or PDF it works perfectly.
Thank you for any kind of help.

Code_Warrior
1st March 2009, 12:52
Are your Windows correct work with symbols of greek alphabet? Are your internet browser correctly open *.htm file which you just saved?
I have the same problem, but with *.odt files. OpenOffice open files which i created in QTextEdit.

P.S. Sorry for my English :)

lixo1
1st March 2009, 13:10
Hi,
I tried with Firefox and Internet Explorer, and Office Word and Openoffice Word, but the problem persists. However on internet explorer I can visualize greek symbols.
This is very strange!

Code_Warrior
1st March 2009, 13:26
I don't know exactly(I'm newbie in Qt) but maybe problem is here, in source code, 'load section':


bool TextEdit::load(const QString &f)
{
if (!QFile::exists(f))
return false;
QFile file(f);
if (!file.open(QFile::ReadOnly))
return false;

QByteArray data = file.readAll();
QTextCodec *codec = Qt::codecForHtml(data);
QString str = codec->toUnicode(data);
if (Qt::mightBeRichText(str)) {
textEdit->setHtml(str);
} else {
str = QString::fromLocal8Bit(data);
textEdit->setPlainText(str);
}

setCurrentFileName(f);
return true;
}

Maybe methods "toUnicode" or "setHtml" change code page or change symbols?

lixo1
2nd March 2009, 12:50
Yes you are wright I think, but when I save using PDF or plain text it works fine.
I tried to create a small gui with QTextEdit and save it, but I got the same results.

lixo1
22nd March 2009, 17:51
Hi everybody,

So would like to know if someone can explain me exactly why we got this problem?

Thank you very much,
Cheers,
Louis