Hi,

Qt Code:
  1. QString QueryDatabase(QString _query){
  2. QSqlDatabase db = QSqlDatabase::addDatabase(type); //Available Types QMYSQL, QPSQL and QSQLITE
  3. db.setDatabaseName(name);
  4. db.setHostName(host);
  5. if(!db.open(user,pass)){
  6. return -1;
  7. }
  8.  
  9. QSqlQuery query;
  10. query.exec(_query);
  11. QString result = query.result(); //How do i do this part
  12. db.close();
  13. return result;
  14. }
To copy to clipboard, switch view to plain text mode 

I want to query the database with string like "select count(*)....." and the return value will always be in one row as its just counting the number of occurances.. how can i get the result direct of the row to QString??

Thanks