QT.zipGuys,

I need help is the first time I'm working with threads and believe I'm doing something wrong. I have a file with the following structure:

Qt Code:
  1. 192.168.0.1 executado OK
  2. 192.168.0.2 erro Sem_Acesso
  3. 192.168.0.3 executado OK
  4. 192.168.0.4 executado OK
  5. 192.168.0.5 executado OK
  6. 192.168.0.6 executado OK
  7. 192.168.0.7 executado OK
  8. 192.168.0.8 executado OK
  9. 192.168.0.9 executado OK
  10. 192.168.0.10 executado OK
  11. 192.168.0.11 executado OK
  12. 192.168.0.12 erro Sem_Acesso
  13. 192.168.0.13 erro Não_Responde_na_Rede
  14. 192.168.0.14 executado OK
To copy to clipboard, switch view to plain text mode 

This file may vary in size, so I'm using the timer and threads, because my idea makes it a first reading and shows on the screen.
After'm trying to use a thread to run in parallel and a timer to wait a few seconds. But I can not do this update.
Following codes:

Corrida.h:
Qt Code:
  1. #ifndef CORRIDA_H
  2. #define CORRIDA_H
  3. #include <QThread>
  4. #include <QTimer>
  5.  
  6. class Corrida : public QThread
  7. {
  8. public:
  9. void tempo();
  10. };
  11.  
  12.  
  13. void Corrida::tempo()
  14. {
  15. QTimer *timer;
  16. timer = new QTimer(this);
  17. connect(timer, SIGNAL(timeout()), this, SLOT(ler_arquivos()));
  18. timer->start(10);
  19. }
  20.  
  21.  
  22. #endif // CORRIDA_H
To copy to clipboard, switch view to plain text mode 

mainwindows.cpp:
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include "Corrida.h"
  4. #include <QStandardPaths>
  5. #include <QFile>
  6. #include <QMessageBox>
  7. #include <QTextStream>
  8. #include <QDir>
  9. #include <QCoreApplication>
  10. #include <QDebug>
  11. #include <QStandardItem>
  12.  
  13. int coluna =0;
  14. int linha = 1;
  15.  
  16. void ler_arquivos();
  17.  
  18. MainWindow::MainWindow(QWidget *parent) :
  19. QMainWindow(parent),
  20. ui(new Ui::MainWindow)
  21. {
  22. ui->setupUi(this);
  23.  
  24. Corrida tempo;
  25. ler_arquivos();
  26. tempo.start();
  27. tempo.wait();
  28. }
  29.  
  30. MainWindow::~MainWindow()
  31. {
  32. delete ui;
  33. }
  34. void MainWindow::ler_arquivos()
  35. {
  36. QFile inputFile("C:\\log_instalador.txt");
  37. if(inputFile.open(QIODevice::ReadOnly))
  38. {
  39. float cont1 = 0;
  40. float cont2 = 0;
  41. float cont3 = 0;
  42. float cont4 = 0;
  43. float porce = 0;
  44.  
  45.  
  46. QTextStream in (&inputFile);
  47. while (!in.atEnd()){
  48.  
  49. ui->tableWidget->setRowCount(linha);
  50. QString line = in.readLine();
  51. QStringList fields = line.split(" ");
  52. QString myS = fields.at(0);
  53. QString mySt = fields.at(1);
  54. QString myStr = fields.at(2);
  55.  
  56. if(QString::compare(fields.at(1),"executado")==0)
  57. {
  58. cont1 +=1;
  59. }
  60. else if(QString::compare(fields.at(1),"erro")==0)
  61. {
  62. cont2 +=1;
  63. }
  64. ui->tableWidget->setItem(coluna,0,new QTableWidgetItem(myS));
  65. ui->tableWidget->setItem(coluna,1,new QTableWidgetItem(mySt));
  66. ui->tableWidget->setItem(coluna,2,new QTableWidgetItem(myStr));
  67. coluna += 1;
  68. linha += 1;
  69. ui->tableWidget->resizeColumnsToContents(); //Dimenciona a celulas
  70. cont3 += 1;
  71. }
  72.  
  73. porce = ((cont1/cont3)*100);
  74. ui->Campo_Verde->setText(QString::number(porce,'f', 0)+" % Executado");
  75. porce = ((cont2/cont3)*100);
  76. ui->Campo_Vermelho->setText(QString::number(porce,'f', 0)+" % com Erro");
  77. porce = ((cont1+cont2)-cont3);
  78. ui->Campo_Amarelo->setText(QString::number(porce,'f', 0)+" % Resta");
  79. porce = (((cont1/cont3)*100)+((cont2/cont3)*100));
  80. ui->Campo_Status->setText(QString::number(porce,'f', 0)+" % Executado");
  81.  
  82.  
  83. qDebug()<< "Quantidade de Executado";
  84. qDebug()<< cont1;
  85. qDebug()<< "Quantidade de Erro";
  86. qDebug()<< cont2;
  87. qDebug()<< "Quantidade total outros";
  88. qDebug()<< cont4;
  89. qDebug()<< "Quantidade total de Linha";
  90. qDebug()<< cont3;
  91. }
  92. inputFile.close();
  93. }
To copy to clipboard, switch view to plain text mode 

Attached is the project file and the *.txt, I'm using for testing:

https://docs.google.com/file/d/0BwQ4...dit?usp=sharin