ruben.rodrigues
7th July 2010, 15:00
Hi all!
I have a client-server application and the network settings are loaded from a txt file that can be overwritten by the administrator but I am have some problems writing the textstream to the file.
the txt file looks like this:
192.168.1.220
11001
this is the function to write:
QFile file("/opt/esp/Client/Settings/CL_settings.txt");
if (!file.open(QIODevice::WriteOnly))
return;
QTextStream out(&file);
out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text() << endl;
the open and reading part works perfectly but when I write with that function, sometime it writes the first line and then the second, other times writes a blank line in the middle, then 2 blank lines, and maybe then back to normal...
I tried other ways:
out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() << "\n"
out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text();
out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() + out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() << "\n"
<< ui.lineEdit_16->text();
they all give me the same problem and my co-worker has a program that does the same thing and it works well for him.
thanks in advance
I have a client-server application and the network settings are loaded from a txt file that can be overwritten by the administrator but I am have some problems writing the textstream to the file.
the txt file looks like this:
192.168.1.220
11001
this is the function to write:
QFile file("/opt/esp/Client/Settings/CL_settings.txt");
if (!file.open(QIODevice::WriteOnly))
return;
QTextStream out(&file);
out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text() << endl;
the open and reading part works perfectly but when I write with that function, sometime it writes the first line and then the second, other times writes a blank line in the middle, then 2 blank lines, and maybe then back to normal...
I tried other ways:
out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() << "\n"
out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text();
out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() + out << ui.lineEdit_17->text();
out << ui.lineEdit_16->text() << "\n"
<< ui.lineEdit_16->text();
they all give me the same problem and my co-worker has a program that does the same thing and it works well for him.
thanks in advance