#include "clients.h"
#include "ui_clients.h"
#include <QSqlQueryModel>
#include <QMessageBox>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlError>
#include <QDebug>
Clients
::Clients(QWidget *parent
) : ui(new Ui::Clients)
{
ui->setupUi(this);
db.setDatabaseName("faktura.sqlite");
db.open();
model->setQuery("SELECT ClientId, ClientName, ClientAddress FROM clients");
model
->setHeaderData
(0, Qt
::Horizontal,
QObject::tr("ID"));
model
->setHeaderData
(1, Qt
::Horizontal,
QObject::tr("company name"));
model
->setHeaderData
(2, Qt
::Horizontal,
QObject::tr("address"));
ui->tableView_clients->setModel(model);
ui->tableView_clients->setColumnWidth(0,100);
ui->tableView_clients->setColumnWidth(1,100);
ui->tableView_clients->setColumnWidth(2,100);
ui
->tableView_clients
->horizontalHeader
()->setResizeMode
(QHeaderView::Interactive);
ui->tableView_clients->horizontalHeader()->setStretchLastSection(true);
ui->tableView_clients->show();
}
Clients::~Clients()
{
delete ui;
}
void Clients::on_pushButton_add_pressed()
{
GroupsAddDialog *dialog=new GroupsAddDialog(this);
dialog->show();
}
#include "clients.h"
#include "ui_clients.h"
#include <QSqlQueryModel>
#include <QMessageBox>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlError>
#include <QDebug>
Clients::Clients(QWidget *parent) :
QDialog(parent),
ui(new Ui::Clients)
{
ui->setupUi(this);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("faktura.sqlite");
db.open();
QSqlQueryModel *model=new QSqlQueryModel();
model->setQuery("SELECT ClientId, ClientName, ClientAddress FROM clients");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("company name"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("address"));
ui->tableView_clients->setModel(model);
ui->tableView_clients->setColumnWidth(0,100);
ui->tableView_clients->setColumnWidth(1,100);
ui->tableView_clients->setColumnWidth(2,100);
ui->tableView_clients->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
ui->tableView_clients->horizontalHeader()->setStretchLastSection(true);
ui->tableView_clients->show();
}
Clients::~Clients()
{
delete ui;
}
void Clients::on_pushButton_add_pressed()
{
GroupsAddDialog *dialog=new GroupsAddDialog(this);
dialog->show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks