title: QT Application Unexplainable crash with Sqlite INSERT function
body: <p>I'm doing calorie counter app. I'm new to QT and this error is way too hard to figure out. I've been thinking more than 3h and nothing.
  here is the function which causes error</p>
  
  <pre><code> bool MainWindow::saveDB()
  {
      loading = true;
      QSqlQuery q(db);
      q.exec("DELETE FROM Food");
      q.prepare("INSERT INTO Food(id,Name,Carbohydrates,Fats,Proteins,Calories) VALUES(:id,:n,:c,:f,:p,:cal)");
          for(int i = 0; i &lt; 1; i++)
          {
                       q.bindValue(":n",ui-&gt;tableWidget-&gt;item(i,1)-&gt;text());
                       q.bindValue(":c",ui-&gt;tableWidget-&gt;item(i,2)-&gt;text().toInt());
                       q.bindValue(":f",ui-&gt;tableWidget-&gt;item(i,3)-&gt;text().toInt());
                       q.bindValue(":p",ui-&gt;tableWidget-&gt;item(i,4)-&gt;text().toInt());
                       q.bindValue(":cal",ui-&gt;tableWidget-&gt;item(i,5)-&gt;text().toInt());
                       q.bindValue(":id",ui-&gt;tableWidget-&gt;item(i,0)-&gt;text().toInt());
               if(!q.exec())
               {
                   qDebug() &lt;&lt; q.lastError().text();
                   loading = false;
                   return false;
               }
          }
      loading = false;
      return true;
  }
  </code></pre>
  
  <p>It is supposed to clear database and it does, and then insert values from tableWidget.</p>
  
  <p>App Output </p>
  
  <pre><code> The program has unexpectedly finished.
  D:\Calc\build-CalcProto-Desktop_Qt_5_4_1_MinGW_32bit-Debug\debug\CalcProto.exe crashed
  </code></pre>
  
  <p>db is my QSqlDatabase object.
  Data is presented in tableWidget which has 6 columns, (id,Name,Carbohydrates,Fats,Proteins,Calories), qDebug doesnt show any message.I tried dozens of variations, it simply always crash.
  There is also loading data function which works perfectly, so the database itself is fine. Update function works fine, but the INSERT always fails. No idea whats wrong. Could you please tell me what is wrong?</p>