aarelovich
20th September 2009, 21:11
Hi
I've written the following code
QString filename;
filename = QFileDialog::getSaveFileName(this,"Choose where to save","","*.jobs");
if (!filename.isEmpty()){
QFile file(filename);
if (file.open(QFile::WriteOnly)){
QTextStream out(&file);
out.setCodec("ISO 8859-1");
out << ui->teScript->toPlainText();
file.close();
}
else
QMessageBox::critical(this,"Error opening file",filename + "\ncould not be opened",QMessageBox::Ok);
}
Where teScript is a QTextEdit. So If I write something like (on the text edit, when executing the program):
Hello
my name is
John
Smith
and then I open the generated txt file (with notepad) i get every line concatenated with a strange square character in the middle.
So I was wondering how I could possibly fix this problem?
PS: The problem is in Windows.
I've written the following code
QString filename;
filename = QFileDialog::getSaveFileName(this,"Choose where to save","","*.jobs");
if (!filename.isEmpty()){
QFile file(filename);
if (file.open(QFile::WriteOnly)){
QTextStream out(&file);
out.setCodec("ISO 8859-1");
out << ui->teScript->toPlainText();
file.close();
}
else
QMessageBox::critical(this,"Error opening file",filename + "\ncould not be opened",QMessageBox::Ok);
}
Where teScript is a QTextEdit. So If I write something like (on the text edit, when executing the program):
Hello
my name is
John
Smith
and then I open the generated txt file (with notepad) i get every line concatenated with a strange square character in the middle.
So I was wondering how I could possibly fix this problem?
PS: The problem is in Windows.