-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatos.cpp
47 lines (41 loc) · 1.15 KB
/
formatos.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "formatos.h"
#include "ui_formatos.h"
Formatos::Formatos(QWidget *parent) :
QDialog(parent),
ui(new Ui::Formatos)
{
ui->setupUi(this);
modelo = new QSqlTableModel(this,QSqlDatabase::database("DB"));
modelo->setTable("formatos");
modelo->setEditStrategy(QSqlTableModel::OnManualSubmit);
modelo->select();
ui->tableView->setModel(modelo);
ui->tableView->resizeColumnsToContents();
ui->tableView->hideColumn(0);
}
Formatos::~Formatos()
{
delete ui;
}
void Formatos::on_pushButtonModificar_clicked()
{
if(!modelo->submitAll()){
QMessageBox::warning(this, "ATENCION",
"No se ha podido modificar el registro"+modelo->lastError().text());
}
}
void Formatos::on_pushButtonnadir_clicked()
{
modelo->insertRow(modelo->rowCount());
}
void Formatos::on_lineEditFiltro_textChanged(const QString &arg1)
{
modelo->setFilter("formato LIKE '%"+arg1+"%'");
}
void Formatos::keyPressEvent(QKeyEvent *e)
{
if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_F11){
ui->pushButtonModificar->setEnabled(true);
ui->pushButtonnadir->setEnabled(true);
}
}