title: How to compare time ranges in text file with time ranges that entered by user in qt?
body: <p>I have a <a href="https://drive.google.com/open?id=0BxZmkxB6kqAkUEZkbl8wODVXNkE" rel="nofollow noreferrer">text file</a> as follows:</p>
  
  <pre><code>05:59:57 - [0x1010001]05:59:57 - (2576) WRITING TO NON-VOLATILE MEMORY IS DONE
  06:00:00 - [0x1010001]06:00:00 - (23371)  T_Check_Buddy !!!  
  06:00:00 - DMA:310127952,01,REQ:BRDTIM 82 07 83 29 05 0f 04 12 06 00 
  06:00:00 - 
  06:00:00 - EvmTbl............
  06:00:00 - Maintenancing &amp; Filling VboxTbl...DONE
  06:00:01 - DMA:310128070,01,IND:KTSPER 96 10 85 fc 00 28 58 
  06:00:01 - DMA:310128071,01,REQ:KTSIDK 82 10 85 fc 81 00 47 02 
  06:00:01 - DMA:310128091,01,IND:KTSPER 96 10 86 fc 00 28 58 
  06:00:01 - DMA:310128091,01,REQ:KTSIDK 82 10 86 fc 81 00 47 02 
  06:00:02 - SIP:310129384, REQ:     KINFO     To:1800 To-Host:192.168.178.230 Ktext: 02 78 0e
  06:00:30 - [0x1010001]06:00:30 - (23371)  T_Check_Buddy !!!  
  06:00:32 - SIP:310159385, REQ:     KINFO     To:1800 To-Host:192.168.178.230 Ktext: 02 78 0e
  06:00:46 - IPT:310173571,255,IND: CONFIG 87 03 4c 43 4e
  </code></pre>
  
  <p>The code is as follows:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include&lt;QFile&gt;
  #include&lt;QTextStream&gt;
  #include&lt;QStringList&gt;
  #include&lt;QDebug&gt;
  #include&lt;QMessageBox&gt;
  
  using namespace std;
  
  MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
  {
     ui-&gt;setupUi(this);
  }
  
  MainWindow::~MainWindow()
  {
     delete ui;
  }
  </code></pre>
  
  <p>I performed button and lineedits in form.After, I splitted time ranges hh:mm:ss format.Because I have to do error checking on time ranges.</p>
  
  <pre><code>void MainWindow::on_pushButton_3_clicked()
  {
     QString output;
     QString line;
     QStringList splitted;
     QString times;
  
     int sayac1=0,sayac2=0;
     bool control1=false;
     bool control2=false;
  
  
     QString firsttime=ui-&gt;lineEdit-&gt;text();  //first time range that entered 
     by user.
     QStringList list1=firsttime.split(":");  //Girilen time split edildi.
  
     if (list1.size() &lt; 3)
       QMessageBox::warning(this,"LIST","ALANLAR BOŞ BIRAKILAMAZ!");
  
     QString hour1=list1[0];
     hour1.toInt();
  
     QString minute1=list1[1];
     minute1.toInt();
  
     QString second1=list1[2];
     second1.toInt();
  
  
     QString secondtime=ui-&gt;lineEdit_2-&gt;text();  //second time range that 
     entered by user. 
     QStringList list2=secondtime.split(":");    //Girilen aralık split 
     edildi.
  
     if(list2.size() &lt; 3)
       QMessageBox::warning(this,"LIST","ALANLAR BOŞ BIRAKILAMAZ!");
  
  
    QString hour2=list2[0];
    hour2.toInt();
  
    QString minute2=list2[1];
    minute2.toInt();
  
    QString second2=list2[2];
    second2.toInt();
  </code></pre>
  
  <p>I read text file and splitted file.I have to need compare time ranges in text file with time ranges that entered by user.</p>
  
  <pre><code>    QFile file("C:\\kaynak\\naile.txt");
  
         if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
  
             QTextStream in(&amp;file);
  
             while(!in.atEnd())
             {
  
                 line = in.readLine()+"\n";
                 output.append(line);
  
  
                 if(line.contains(" - ")){
                     splitted=line.split(" - ");
                     times=times+" "+splitted[0];
                 }
  
                 if(splitted[0]!=firsttime &amp;&amp; control1==false){
                    sayac1 = sayac1+1;
                 }
                 else
                    control1=true;
  
  
                 if(splitted[0]!=secondtime &amp;&amp; control2==false){
                    sayac2++;
                 }
                 else
                    control2=true;
  
  }
  </code></pre>
  
  <p>In following code,I did error checking as I mentioned above.And,I tried display records at specified time intervals.But when I run the code,nothing seems in textbrowser that I created to display records.I don't understand why this is happening.Also,no error occurs.For example,user entered 05:59:57 to first lineedit and 06:00:46 to second lineedit.Then user clicked button to display records at this time intervals.I want to display records from 05:59:57 to 06:00:46.But,there are no records in textbrowser.Nothing seems.HOW CAN I SOLVE THIS PROBLEM?</p>
  
  <pre><code>      if(hour1&lt;=hour2){
  
          int i;
          QString list;
          QString newline=splitted[0]+" - "+splitted[1];
          list.append(newline);
  
          if(times.contains(firsttime) &amp;&amp; times.contains(secondtime)){
  
             for(i=sayac1+1;i&lt;=sayac2+1;i++){
                  ui-&gt;textBrowser_3-&gt;setText(list.at(i));
             }
  
         }
  
          else
             QMessageBox::warning(this,"LIST","GİRDİĞİNİZ ZAMAN ARALIKLARI 
             EŞLEŞMİYOR!");
          }
  
  
          if(hour1&gt;hour2)
             QMessageBox::warning(this,"LIST","İKİNCİ SAAT BİRİNCİDEN BÜYÜK 
             OLAMAZ!");
  
  
  
             file.close();
            // return output;
  
    }
  }
  </code></pre>