-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.cpp
More file actions
55 lines (50 loc) · 1.35 KB
/
Copy pathquery.cpp
File metadata and controls
55 lines (50 loc) · 1.35 KB
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
48
49
50
51
52
53
54
55
#include "query.h"
#include "ui_query.h"
// 构造函数
Query::Query(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Query)
{
ui->setupUi(this);
ui->IDradioButton->setChecked(true); // 默认选择ID查询
// getvector();
}
// 获取员工数据容器
void Query::getvector(vector<QPointer<Company>>&tem){
v=tem;
}
// 返回按钮槽函数
void Query::on_btnqueryback_clicked(){
emit this->backquery();
}
// 查询按钮点击事件
void Query::on_QpushButton_clicked(){
QString s=ui->InlineEdit->text();
if(s==""){
ui->InlineEdit->setText("请输入要查询的信息");
return;
}
// 根据选择的查询条件(ID或姓名)进行员工信息查询
if(ui->IDradioButton->isChecked()){
for(auto &it:v)
if(QString::number((*it).id)==s){
QString text=(*it).toString('\n');
ui->Outlabel->setText(text);
return;
}
}
else if(ui->NameradioButton->isChecked()){
for(auto &it:v)
if(QString::fromStdString((*it).name)==s){
QString text=(*it).toString('\n');
ui->Outlabel->setText(text);
return;
}
}
ui->Outlabel->setText("查无此人");
}
// 析构函数
Query::~Query()
{
delete ui;
}