Partners
::Partners(QWidget *parent
) : ui(new Ui::Partners)
{
ui->setupUi(this);
model->setQuery("SELECT Name, City, Bulstat FROM partners");
model
->setHeaderData
(0, Qt
::Horizontal,
QObject::tr("Име"));
model
->setHeaderData
(1, Qt
::Horizontal,
QObject::tr("Град"));
model
->setHeaderData
(2, Qt
::Horizontal,
QObject::tr("ЕИК:"));
ui->tableView_partners->setModel(model);
ui->tableView_partners->setColumnWidth(0,325);
ui->tableView_partners->setColumnWidth(1,200);
ui->tableView_partners->setColumnWidth(2,200);
ui
->tableView_partners
->horizontalHeader
()->sectionResizeMode
(QHeaderView::Interactive);
ui->tableView_partners->show();
}
Partners::~Partners()
{
delete ui;
}
void Partners::addPartner()
{
query.prepare("INSERT INTO partners (Name, City, Address, MOL, Bulstat, VAT, Phone, eMail)"
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
query.addBindValue(1);
query.addBindValue(2);
query.addBindValue(3);
query.addBindValue(4);
query.addBindValue(5);
query.addBindValue(6);
query.addBindValue(7);
query.addBindValue(8);
query.exec();
model->setQuery("SELECT Name, City, Bulstat FROM partners");
ui->tableView_partners->setModel(model);
qDebug() << "record added";
}
Partners::Partners(QWidget *parent) :
QWidget(parent),
ui(new Ui::Partners)
{
ui->setupUi(this);
QSqlQueryModel *model = new QSqlQueryModel(this);
model->setQuery("SELECT Name, City, Bulstat FROM partners");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Име"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Град"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("ЕИК:"));
ui->tableView_partners->setModel(model);
ui->tableView_partners->setColumnWidth(0,325);
ui->tableView_partners->setColumnWidth(1,200);
ui->tableView_partners->setColumnWidth(2,200);
ui->tableView_partners->horizontalHeader()->sectionResizeMode(QHeaderView::Interactive);
ui->tableView_partners->show();
}
Partners::~Partners()
{
delete ui;
}
void Partners::addPartner()
{
QSqlQuery query;
query.prepare("INSERT INTO partners (Name, City, Address, MOL, Bulstat, VAT, Phone, eMail)"
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
query.addBindValue(1);
query.addBindValue(2);
query.addBindValue(3);
query.addBindValue(4);
query.addBindValue(5);
query.addBindValue(6);
query.addBindValue(7);
query.addBindValue(8);
query.exec();
QSqlQueryModel *model = new QSqlQueryModel(this);
model->setQuery("SELECT Name, City, Bulstat FROM partners");
ui->tableView_partners->setModel(model);
qDebug() << "record added";
}
To copy to clipboard, switch view to plain text mode
Bookmarks