#include "PersonListForm.h" #include "ui_PersonListForm.h" PersonListForm::PersonListForm(QWidget *parent) : QWidget(parent), ui(new Ui::PersonListForm) { ui->setupUi(this); // 加载css文件设置控件样式 QFile file(QApplication::applicationDirPath() + "/qss/personList.css"); if (file.open(QFile::ReadOnly)) { QString qssStr = QLatin1String(file.readAll()); this->setStyleSheet(qssStr); file.close(); } // 设置弹簧的尺寸 ui->vsContentTop->changeSize(0, 20); ui->vsTableTop->changeSize(0, 20); ui->vsContentBottom->changeSize(0, 40); itemModel = new QStandardItemModel(this); personList = new QList<QVariantMap>(); SelectDeptUtil::getInstance().initSelectDept(ui->selectDept, CacheManager::getInstance().getDeptCachePtr()); QStringList header; header << "员工编号" << "姓名" << "部门 "<< "采集特征" << "操作"; itemModel->setHorizontalHeaderLabels(header); for (int i = 0; i < tableRowCount; i++) { QList<QStandardItem *> row; for ( int j = 0; j < tableColCount; j++) { itemModel->setItem(i, j, new QStandardItem(QString(""))); itemModel->item(i, j)->setTextAlignment(Qt::AlignCenter); } } ui->personListTable->setModel(itemModel); ui->personListTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); // 设置每行的高度 for ( int i = 0; i < tableRowCount; i++) { ui->personListTable->setRowHeight(i, 50); } // 设置每列的宽度 ui->personListTable->setColumnWidth(0, 150); ui->personListTable->setColumnWidth(1, 226); // =1280-100-100-4-other col ui->personListTable->setColumnWidth(2, 400); ui->personListTable->setColumnWidth(3, 150); ui->personListTable->setColumnWidth(4, 150); } PersonListForm::~PersonListForm() { delete ui; } void PersonListForm::findPersonList() { SysPersonDao personDao; QVector<QVariantMap> perList = personDao.findAllRecord(); this->personList->clear(); for (int i = 0; i < perList.size(); i++) { QVariantMap person = perList.at(i); this->personList->append(person); } } void PersonListForm::updatePersonListTable() { } void PersonListForm::on_btnRegist_clicked() { emit switchToRegistForm("0"); } void PersonListForm::on_btnHome_clicked() { emit backToHomePage(); } void PersonListForm::on_btnBack_clicked() { emit backToHomePage(); }