Hello everyone. I´m Spawnsito and I need help.

I am making an application where I need to read a file too heavy. The file has a default format:
XXXXX, YYYYYY, HEIGHT -> all are number.

I'm reading this file from a QThread through QTextStream. Everything works fine until the thread emit the progress that has processed the file. At iteration after emit, the function readline() in QTextStream take a partial string of the file.

If I remove the emit of the sign of progress, the thread is working properly, however the progress bar is not useful.

I hope I have explained my problem correctly.

Qt Code:
  1. void CargarDemThread::run(){
  2. float altura;
  3. QFile file(_rutaDem);
  4. int progreso = 1;
  5. if (file.open(QIODevice::Text | QIODevice::ReadOnly)){
  6. qint64 size = file.size();
  7. QTextStream in(&file);
  8. while(!in.atEnd()){
  9. f = in.readLine();
  10. sl = f.split(",");
  11. altura = sl.at(2).toFloat();
  12. _dem->addValue(altura);
  13. if (in.pos/size()*100>progreso){
  14. emit progress(progreso);
  15. progreso++;
  16. }
  17. }
  18. }
To copy to clipboard, switch view to plain text mode