-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
45 lines (39 loc) · 874 Bytes
/
widget.cpp
File metadata and controls
45 lines (39 loc) · 874 Bytes
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
#include "widget.h"
#include "ui_widget.h"
#include <mysql.h>
#include<main.cpp>
#include<QDebug>
#include<mainwindow.h>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
db=QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("address_manage");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("123456");
db.open();
}
Widget::~Widget()
{
delete ui;
db.close();
}
void Widget::on_loginpushButton_clicked()
{
this->hide();
MainWindow *c=new MainWindow;
if(db.open()){
QMessageBox::information(this,"连接提示","连接成功");
}
else{
QMessageBox::information(this,"连接提示","连接失败");
}
c->show();
}
void Widget::on_outpushButton_clicked()
{
exit(0);
}