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:

Qt Code:
  1. QFile file("/opt/esp/Client/Settings/CL_settings.txt");
  2. if (!file.open(QIODevice::WriteOnly))
  3. return;
  4.  
  5. QTextStream out(&file);
  6. out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text() << endl;
To copy to clipboard, switch view to plain text mode 

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:

Qt Code:
  1. out << ui.lineEdit_16->text() << "\n" << ui.lineEdit_17->text();
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. out << ui.lineEdit_16->text() << "\n"
  2. out << ui.lineEdit_17->text();
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. out << ui.lineEdit_16->text();
  2. out << ui.lineEdit_17->text();
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. out << ui.lineEdit_16->text() + out << ui.lineEdit_17->text();
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. out << ui.lineEdit_16->text() << "\n"
  2. << ui.lineEdit_16->text();
To copy to clipboard, switch view to plain text mode 

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