1  void MainWindow::on_deleteButton_clicked()
2  {
3     if (ui->delEdit->text() == "") {
4        QMessageBox::information(this, "Warning", "Enter a student number to delete");
5        return;
6     }
7     int sno = ui->delEdit->text().toInt();
8     QSqlQuery q;
9     QString qs = "delete from Student where stNo = '" + QString::number(sno) + "' ";
10    q.exec(qs);
11    if (q.numRowsAffected() == 0)     {
12      QMessageBox::information(this, "Error", "Record not Found");
13      return;
14    }
15    else
16        QMessageBox::information(this, "Info", "Record was deleted ");
17 }