-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.cpp
More file actions
58 lines (51 loc) · 1.37 KB
/
employee.cpp
File metadata and controls
58 lines (51 loc) · 1.37 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
56
57
58
#include "employee.h"
#include "mainwindow.h"
#include "ui_employee.h"
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QDebug>
Employee::Employee(QWidget *parent) :
QDialog(parent),
ui(new Ui::Employee)
{
ui->setupUi(this);
fillComboBox();
}
Employee::~Employee()
{
delete ui;
}
void Employee::on_pushButton_clicked()
{
close();
}
void Employee::fillComboBox() //This function was supposed to fill the comboBox by reading the names in from the
//file just like the textEdit, but does not work properly.
{
QFile file(":/storedInfo/contact.txt");
QTextStream in(&file);
while(!in.atEnd())
{
QString line = in.readLine();
QString name = line.section(',',0,0);
ui->comboBox->addItem(name);
}
}
void Employee::fillLineEdits() //Basically the same as the function above but for the lineEdits
{
QFile file(":/storedInfo/contact.txt");
QTextStream in(&file);
while(!in.atEnd())
{
QString line = in.readLine();
QString name = line.section(',',0,0);
QString email = line.section(',',1,1);
QString hphone = line.section(',',2,2);
QString cphone = line.section(',',3,3);
ui->lineEdit->setText(name);
ui->lineEdit->setText(email);
ui->lineEdit->setText(hphone);
ui->lineEdit->setText(cphone);
}
}