Creating a database table
In this recipe, we will be learning to create a database table. The user will be prompted to specify the database name, followed by the table name that is to be created. The recipe enables you to enter column names and their data types. Upon clicking the push button, the table with the defined columns will be created in the specified database.
How to do it…
Here are the steps to create a GUI that enables the user to enter all the information for the database table to be created. Using this GUI, the user can specify the database name, column names, and choose column types too:
- Let's create an application based on the
Dialog without Buttons
template. - Add fiveÂ
QLabel
, threeQLineEdit
, oneÂQComboBox
, and twoQPushButton
widgets to the form by dragging and dropping fiveLabel
, threeLine Edit
, oneÂCombo Box
, and twoPush Button
widgets on the form. - Set the
text
property of the first fourLabel
widgets toEnter database name
,Enter table name
,Column Name
, andData Type
. - Delete...