#include "showtable.h"
#include "ui_showtable.h"

ShowTable::ShowTable(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ShowTable)
{
    ui->setupUi(this);
}

ShowTable::~ShowTable()
{
    delete ui;
}


void ShowTable::dowork(QSqlDatabase db,QString tablename)
{
    QSqlTableModel *model = new QSqlTableModel(ui->tableView,db);
    model->setTable(tablename);
    model->select();
    model->setHeaderData(0,Qt::Horizontal,QObject::tr("编号"));
    model->setHeaderData(1,Qt::Horizontal,QObject::tr("usrname"));
    model->setHeaderData(2,Qt::Horizontal,QObject::tr("psw"));
    ui->tableView->setModel(model);
}

void ShowTable::on_close_clicked()
{
    this->close();
}
