Sohag Developer PostgreSQL Database Applications

Build Powerful Robust Database Applications

Simple Template Part 1

Sat, 08/11/2018 - 12:06 - amr

Simple Generator
This template uses Qt low level SQL API to interact with the database table or view.
The Simple Template has some advanced functionality not just contains UI and the generated Qt/C++ code that executes the SQL DML, But also contains a set of control buttons that are connected corresponding set of slots to execute query, new, delete, save and close operations.
So this template is ready to use and may not need any changes from the developer.
Files generated by Simple Generator.

1- A Qt project file (.pro file) for every Sohag Developer project.
2- A C++ main file (main.cpp file contains main function) for every Sohag Developer project.
3- Qt UI file (.ui file) for every class or database table or view.
4- C++ header file (.h) for every class or database table or view.
5- C++ implementation file (.cpp file) for every class or database table or view.

In the next sections you will find explanation for every file and its main contents with an example.
The example is built on database table customers
SQL DDL for creating customers table (this structure for PostgreSQL database)


CREATE TABLE cust.customers
(
  cust_id integer NOT NULL,
  customer character varying(200),
  address character varying(500),
  phone character varying(20),
  mobile character varying(20),
  email character varying(50),
  fax character varying(20),
  notes character varying(500),
  CONSTRAINT customers_pkey PRIMARY KEY (cust_id)
)
WITH (
  OIDS=FALSE
);

1- A Qt project file (.pro file) for every Sohag Developer project.
This file contains description and informations that qmake uses to generate the make file for the project


QT       += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = customer
TEMPLATE = app
SOURCES += main.cpp\
        customers.cpp
HEADERS  += customers.h
FORMS    += customers.ui

2- A C++ main file (main.cpp file contains main function) for every Sohag Developer project.
This file contains the main function, Basic generator uses the first class in the project in the main function.


#include "customers.h"
#include <QApplication>


int main(int argc, char *argv[])
{
    QApplication sohag(argc, argv);
	
    Customers sohagDev;
    sohagDev.show();

    return sohag.exec();
}

Simple Template Part 2

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.