1 void MainWindow::on_searchButton_clicked()
2 {
3    if (ui->searchEdit->text() == "") {
4        QMessageBox::information(this, "Warning", "Enter a student number to search");
5        return;
6    }
7    int sno = ui->searchEdit->text().toInt();
8    QSqlQuery q;
9    QString qs = "select * from Student where stNo = '" + QString::number(sno) + "' ";
10   q.exec(qs);
11   if (!q.first())  {
12     QMessageBox::information(this, "Error", "Record not Found");
13     return;
14    }
15   else {
16        QSqlQueryModel *qm = new QSqlQueryModel();
17        qm->setQuery(q);
18        SecondWindow *secwin = new SecondWindow();
19        secwin->setWindowTitle("Output Window");
20        QTableView *table = new QTableView();
21        secwin->setCentralWidget(table);
22        table->setModel(qm);
23        secwin->show();
24        db.close();
25    }
26 }