Let's create a simple program that demonstrates basic SQL query commands by following these steps:
- We can use our previous project files, but there are a couple of things we need to change. Open mainwindow.ui and replace the labels for Name and Age with line-edit widgets. Then, add three buttons to the canvas and call them UPDATE, INSERT, and DELETE:
- Open mainwindow.h and add the following variables under the private inheritance:
private: Ui::MainWindow *ui; QSqlDatabase db; bool connected; int currentID;
- Open mainwindow.cpp and go to the class constructor. It is still pretty much the same as the previous example, except ...