基于物联网地铁自动售票检票智能系统

简易记录一下代码之后再完善

.pro文件

#-------------------------------------------------
#
# Project created by QtCreator 2023-02-01T09:38:10
#
#-------------------------------------------------

QT       += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled15
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

RC_ICONS = th1.ico

SOURCES += \
        main.cpp \
        widget.cpp \
    kaiguan.cpp \
    chufa.cpp \
    daoda.cpp \
    chupiao.cpp \
    chepiaoxinxi.cpp \
    chepiaoxinxijihe.cpp \
    showchepiao.cpp \
    form.cpp \
    messagew.cpp \
    formrengong.cpp

HEADERS += \
        widget.h \
    kaiguan.h \
    chufa.h \
    daoda.h \
    chupiao.h \
    chepiaoxinxi.h \
    chepiaoxinxijihe.h \
    showchepiao.h \
    form.h \
    messagew.h \
    formrengong.h

FORMS += \
        widget.ui \
    form.ui \
    formrengong.ui

RESOURCES += \
    tupian.qrc

Headers文件

1.chepiaoxinxi.h文件

#ifndef CHEPIAOXINXI_H
#define CHEPIAOXINXI_H
#include 

class ChePiaoXinXi
{
public:
    int id;//车票id
    QString start_name;//车票出发站名称
    QString end_name;//车票到达站名称
    int money;//车票价格
    int zhuangtai;//车票状态,0表示新购的车票,1表示已经进站,2表示已经出站
    ChePiaoXinXi();
    ChePiaoXinXi(int id1,QString start_name1,QString end_name1,int money1,int zhuangtai1);
};

#endif // CHEPIAOXINXI_H

2.chepiaoxinxijihe.h

#ifndef CHEPIAOXINXIJIHE_H
#define CHEPIAOXINXIJIHE_H
#include 
#include 
#include "chepiaoxinxi.h"
class ChePiaoXinXiJiHe
{
public:
    //泛型,这个集合里放这种类型的数据
    static QList chepiaoList;
    ChePiaoXinXiJiHe();
    static int addChePiaoXinXi(int id1,QString start_name1,QString end_name1,int money1,int zhuangtai1);
};

#endif // CHEPIAOXINXIJIHE_H

3.chufa.h

#ifndef CHUFA_H
#define CHUFA_H

#include 
#include 
#include 
#include "kaiguan.h"
class ChuFa : public QWidget
{
    Q_OBJECT
public:
    explicit ChuFa(QWidget *parent = nullptr);
    QLabel label;
    QPushButton button_ok;
    QPushButton button_can;
    void button_can_clicked();//button_can按钮的槽函数
    void button_ok_clicked();//button_ok按钮的槽函数

signals:

public slots:
};

#endif // CHUFA_H

4.chupiao.h

#ifndef CHUPIAO_H
#define CHUPIAO_H

#include 
#include 
#include 
#include "kaiguan.h"
#include "chepiaoxinxi.h"
#include "chepiaoxinxijihe.h"
#include 
#include "showchepiao.h"
#include 
#include 
class ChuPiao : public QWidget
{
    Q_OBJECT
public:
    explicit ChuPiao(QWidget *parent = nullptr);
    QLabel label;
    QPushButton button_ok;
    QPushButton button_can;
    void button_can_clicked();//button_can按钮的槽函数
    void button_ok_clicked();//button_ok按钮的槽函数
    ShowChePiao showchepiao;
    static const QHash> mp;
signals:

public slots:
};

#endif // CHUPIAO_H

5.daoda.h

#ifndef DAODA_H
#define DAODA_H

#include 
#include 
#include 
#include "kaiguan.h"
#include "chupiao.h"
class DaoDa : public QWidget
{
    Q_OBJECT
public:
    explicit DaoDa(QWidget *parent = nullptr);
    QLabel label;
    QPushButton button_ok;
    QPushButton button_can;
    void button_can_clicked();//button_can按钮的槽函数
    void button_ok_clicked();//button_ok按钮的槽函数
    ChuPiao chupiao;
signals:

public slots:
};

#endif // DAODA_H

6.form.h

#ifndef FORM_H
#define FORM_H

#include 
#include 
#include "chepiaoxinxi.h"
#include "chepiaoxinxijihe.h"
#include "messagew.h"
namespace Ui {
class Form;
}

class Form : public QWidget
{
    Q_OBJECT

public:
    explicit Form(QWidget *parent = 0);
    ~Form();
    int zhaojiOK(int id1,QString zhangming,QString jinchu);
    MessageW messsage;
    void chepiaojiemian(QString str);
private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_6_clicked();

    void on_pushButton_7_clicked();

    void on_pushButton_8_clicked();

    void on_pushButton_9_clicked();

    void on_pushButton_10_clicked();

    void on_pushButton_12_clicked();

    void on_pushButton_11_clicked();

    void on_pushButton_25_clicked();

    void on_pushButton_26_clicked();

    void on_pushButton_32_clicked();

    void on_pushButton_31_clicked();

    void on_pushButton_28_clicked();

    void on_pushButton_27_clicked();

    void on_pushButton_13_clicked();

    void on_pushButton_14_clicked();

    void on_pushButton_15_clicked();

    void on_pushButton_16_clicked();

    void on_pushButton_17_clicked();

    void on_pushButton_18_clicked();

    void on_pushButton_29_clicked();

    void on_pushButton_30_clicked();

    void on_pushButton_19_clicked();

    void on_pushButton_21_clicked();

    void on_pushButton_20_clicked();

    void on_pushButton_22_clicked();

    void on_pushButton_23_clicked();

    void on_pushButton_24_clicked();

    void on_pushButton_34_clicked();

    void on_pushButton_33_clicked();

    void on_pushButton_35_clicked();

    void on_pushButton_36_clicked();

private:
    Ui::Form *ui;
};

#endif // FORM_H

7.formrengong.h文件

#ifndef FORMRENGONG_H
#define FORMRENGONG_H

#include 
#include  //数据模型
#include "chepiaoxinxi.h"
#include "chepiaoxinxijihe.h"
//QSqlTableModel数据模型里放数据,显示数据模型中的数据,QTableView
//QSqlTableModel->QTableView
namespace Ui {
class FormRenGong;
}

class FormRenGong : public QWidget
{
    Q_OBJECT

public:
    explicit FormRenGong(QWidget *parent = 0);
    ~FormRenGong();

private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void UpdateChePiao();
private:
    Ui::FormRenGong *ui;
    QSqlTableModel *model;
};

#endif // FORMRENGONG_H

8.kaiguan.h文件

#ifndef KAIGUAN_H
#define KAIGUAN_H
#include 

class KaiGuan
{
public:
    KaiGuan();
    static int cf;//记录出发状态,cf=0表示没有出发,cf=1表示已经出发
    static int dd;//记录到达状态,dd=0表示没有到达,dd=1表示已经到达
    static int start;//记录出发站的下标
    static int end;//记录到达站下标
    static QString names[18];
    static int new_id;//记录最新车票的id

};

#endif // KAIGUAN_H

9.messagew.h文件

#ifndef MESSAGEW_H
#define MESSAGEW_H

#include 
#include 
class MessageW : public QWidget
{
    Q_OBJECT
public:
    explicit MessageW(QWidget *parent = nullptr);
    QLabel label;
signals:

public slots:
};

#endif // MESSAGEW_H

10.showchepiao.h文件

#ifndef SHOWCHEPIAO_H
#define SHOWCHEPIAO_H

#include 
#include 
#include 
class ShowChePiao : public QWidget
{
    Q_OBJECT
public:
    explicit ShowChePiao(QWidget *parent = nullptr);
    QLabel label;
signals:

public slots:
};

#endif // SHOWCHEPIAO_H

11.widget.h文件

#ifndef WIDGET_H
#define WIDGET_H

#include 
//导入出发窗口头文件
#include "chufa.h"
#include "kaiguan.h"
#include "daoda.h"
#include 
#include 
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    ChuFa chufa;//定义出发窗口对象
    DaoDa daoda;//定义到达窗口对象
private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_13_clicked();

    void on_pushButton_15_clicked();

    void on_pushButton_7_clicked();

    void on_pushButton_6_clicked();

    void on_pushButton_8_clicked();

    void on_pushButton_16_clicked();

    void on_pushButton_9_clicked();

    void on_pushButton_14_clicked();

    void on_pushButton_17_clicked();

    void on_pushButton_10_clicked();

    void on_pushButton_18_clicked();

    void on_pushButton_11_clicked();

private:
    Ui::Widget *ui;
};

#endif // WIDGET_H

Sources文件

1.chepiaoxinxi.cpp

#include "chepiaoxinxi.h"

ChePiaoXinXi::ChePiaoXinXi()
{

}
ChePiaoXinXi::ChePiaoXinXi(int id1,QString start_name1,QString end_name1,int money1,int zhuangtai1){
   id=id1;
   start_name=start_name1;
   end_name=end_name1;
   money=money1;
   zhuangtai=zhuangtai1;
}

2.chepiaoxinxijihe.cpp

#include "chepiaoxinxijihe.h"

ChePiaoXinXiJiHe::ChePiaoXinXiJiHe()
{

}
QList ChePiaoXinXiJiHe::chepiaoList={};
int ChePiaoXinXiJiHe::addChePiaoXinXi(int id1,QString start_name1,QString end_name1,int money1,int zhuangtai1){
    //chepiaoList.count()统计集合中有多少对象
    //统计集合中有多少张车票
    if(chepiaoList.count()==0){
        id1=0;
        ChePiaoXinXi cp(id1,start_name1,end_name1,money1,zhuangtai1);
        chepiaoList.append(cp);
        return cp.id;
    }
    else {
        //先取到最后一张车票
        //取最后一张车票的id
        ChePiaoXinXi cp=chepiaoList.last();
        //取最后一张车票的id
        //取最后一张车票的id+1就是新车票的id
        id1=cp.id+1;
        ChePiaoXinXi new_cp(id1,start_name1,end_name1,money1,zhuangtai1);
        chepiaoList.append(new_cp);
        return new_cp.id;

    }
}

3.chufa.cpp

#include "chufa.h"
#include 
ChuFa::ChuFa(QWidget *parent) : QWidget(parent)
{
    label.setParent(this);//设置标签的父窗口
    label.setText("您确定从此站出发?");//设置标签的文本
    QFont ft;//定义字体对象
    ft.setPointSize(20);//设置字体大小为20号
    label.setFont(ft);//设置标签的字体为ft
    label.move(80,80);//设置标签的位置
    label.resize(380,60);
    button_ok.setParent(this);//设置确定按钮父窗口
    button_ok.setText("确定");//设置确定按钮文本
    button_ok.move(80,200);//设置确定按钮位置
    button_can.setParent(this);
    button_can.setText("取消");
    button_can.move(280,200);
    connect(&button_can,&QPushButton::clicked,this,&ChuFa::button_can_clicked);
    connect(&button_ok,&QPushButton::clicked,this,&ChuFa::button_ok_clicked);

}
void ChuFa::button_can_clicked(){
    KaiGuan::cf=0;
    KaiGuan::dd=0;
    this->close();

}
void ChuFa::button_ok_clicked(){
    KaiGuan::cf=1;
    KaiGuan::dd=0;
    this->close();
}

4.chupiao.cpp

#include "chupiao.h"
//集合头文件  数组
#include 
//数组  字节数组头文件
#include 
#include 
#include 
//时间头文件   小时  分  秒
#include
//日期头文件  年  月  日
#include
#include 
//数据库头文件
#include 
#include 
//弹出消息框头文件
#include 
//数据库错误处理头文件
#include 
#include 
//数据库查询头文件
#include 
//数据参数绑定头文件
#include 
#include 
const QHash> ChuPiao::mp={
        {"静安寺",{4,2}},
        {"南京西路",{4,4}},
        {"人民广场",{4,6}},
        {"南京东路",{4,8}},
        {"陆家嘴",{5,10}},
        {"东昌路",{6,12}},
        {"常熟路",{8,2}},
        {"陕西南路",{8,4}},
        {"新天地",{9,5}},
        {"老西门",{9,7}},
        {"大世界",{5,7}},
        {"黄陂南路",{6,5}},
        {"豫园",{6,8}},
        {"天潼路",{3,8}},
        {"国际客运中心",{2,10}},
        {"曲阜路",{2,6}},
        {"汉中路",{2,4}},
        {"长寿路",{2,2}},
    };

ChuPiao::ChuPiao(QWidget *parent) : QWidget(parent)
{
    label.setParent(this);//设置标签的父窗口
    QFont ft;//定义字体对象
    ft.setPointSize(20);//设置字体大小为20号
    label.setFont(ft);//设置标签的字体为ft
    label.move(20,80);//设置标签的位置
    label.resize(500,60);
    button_ok.setParent(this);//设置确定按钮父窗口
    button_ok.setText("确定");//设置确定按钮文本
    button_ok.move(80,200);//设置确定按钮位置
    button_can.setParent(this);
    button_can.setText("取消");
    button_can.move(280,200);
    connect(&button_ok,&QPushButton::clicked,this,&ChuPiao::button_ok_clicked);
    connect(&button_can,&QPushButton::clicked,this,&ChuPiao::button_can_clicked);
}
void ChuPiao::button_ok_clicked(){
    int id1=0;
    QString start_name1=KaiGuan::names[KaiGuan::start];
    QString end_name1=KaiGuan::names[KaiGuan::end];

    //计算两点距离dist
    int dist=abs(mp[start_name1].first-mp[end_name1].second)+abs(mp[start_name1].second-mp[end_name1].second);


    /*
    /*    每次费用计算规则:
    /*    起步价:首4公里人民币2元;
    /*    4公里至12公里部分,每人民币1元可乘坐4公里;
    /*    12公里至24公里部分,每人民币1元可乘坐6公里;
    /*    超过24公里,每人民币1元可乘坐8公里。
    */
    int money1;
    if(dist<=4)money1=2;
    else if(dist<=12)money1=2+(dist-4)/4*1;
    else if(dist<=24)money1=4+(dist-12)/6*1;
    else money1=10+(dist-24)/8;


    int zhuangtai1=0;
    KaiGuan::new_id= ChePiaoXinXiJiHe::addChePiaoXinXi(id1,start_name1,end_name1,money1,zhuangtai1);
    ChePiaoXinXi cp=ChePiaoXinXiJiHe::chepiaoList.last();


    QString str=QString("车票id:%1  出发站:%2 -> 到达站:%3,费用为 %4 元").arg(cp.id).arg(cp.start_name).arg(cp.end_name).arg(cp.money);
    showchepiao.label.setText(str);
    showchepiao.setFixedSize(800,200);


    //QTime类  QTime::currentTime()获取当前时间
    QTime time=QTime::currentTime();
    //time.toString("hh:mm:ss")将时间以小时:分:秒的格式转化为字符串
    QString str1=time.toString("hh:mm:ss");
    qDebug()<close();
}
void ChuPiao::button_can_clicked(){
    KaiGuan::cf=0;
    KaiGuan::dd=0;
    this->close();
}

5.daoda.cpp

#include "daoda.h"
#include 
DaoDa::DaoDa(QWidget *parent) : QWidget(parent)
{
    label.setParent(this);//设置标签的父窗口
    label.setText("您确定到达此站?");//设置标签的文本
    QFont ft;//定义字体对象
    ft.setPointSize(20);//设置字体大小为20号
    label.setFont(ft);//设置标签的字体为ft
    label.move(80,80);//设置标签的位置
    label.resize(380,60);
    button_ok.setParent(this);//设置确定按钮父窗口
    button_ok.setText("确定");//设置确定按钮文本
    button_ok.move(80,200);//设置确定按钮位置
    button_can.setParent(this);
    button_can.setText("取消");
    button_can.move(280,200);
    connect(&button_can,&QPushButton::clicked,this,&DaoDa::button_can_clicked);
    connect(&button_ok,&QPushButton::clicked,this,&DaoDa::button_ok_clicked);
}
void DaoDa::button_can_clicked(){
    KaiGuan::cf=0;
    KaiGuan::dd=0;

    this->close();
}
void DaoDa::button_ok_clicked(){
    KaiGuan::cf=0;
    KaiGuan::dd=1;
    QString str="确认出票,出发站:"+KaiGuan::names[KaiGuan::start]+"->到达站:"+KaiGuan::names[KaiGuan::end];
    chupiao.label.setText(str);
    chupiao.setFixedSize(700,300);
    chupiao.show();
    this->close();
}

6.form.cpp

#include "form.h"
#include "ui_form.h"
#include 
#include 
//数组  字节数组头文件
#include 
#include 
#include 
//时间头文件   小时  分  秒
#include
//日期头文件  年  月  日
#include
#include 
//数据库头文件
#include 
#include 
//弹出消息框头文件
#include 
//数据库错误处理头文件
#include 
#include 
//数据库查询头文件
#include 
//数据参数绑定头文件
#include 
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
}

Form::~Form()
{
    delete ui;
}
int Form::zhaojiOK(int id1,QString zhangming,QString jinchu){
    int i=0;//循环变量
    for(i=0;ilineEdit->text().toInt();
    //QString str=ui->pushButton->text();
    //qDebug()< list1=str.split(",");
    //qDebug()<pushButton->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_2_clicked()
{
    QString str=ui->pushButton_2->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_4_clicked()
{
    QString str=ui->pushButton_4->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_6_clicked()
{
    QString str=ui->pushButton_6->text();
    chepiaojiemian(str);

}

void Form::on_pushButton_7_clicked()
{
    QString str=ui->pushButton_7->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_8_clicked()
{
    QString str=ui->pushButton_8->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_9_clicked()
{
    QString str=ui->pushButton_9->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_10_clicked()
{
    QString str=ui->pushButton_10->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_12_clicked()
{
    QString str=ui->pushButton_12->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_11_clicked()
{
    QString str=ui->pushButton_11->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_3_clicked()
{
    QString str=ui->pushButton_3->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_5_clicked()
{
    QString str=ui->pushButton_5->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_25_clicked()
{
    QString str=ui->pushButton_25->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_26_clicked()
{
    QString str=ui->pushButton_26->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_32_clicked()
{
    QString str=ui->pushButton_32->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_31_clicked()
{
    QString str=ui->pushButton_31->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_28_clicked()
{
    QString str=ui->pushButton_28->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_27_clicked()
{
    QString str=ui->pushButton_27->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_13_clicked()
{
    QString str=ui->pushButton_13->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_14_clicked()
{
    QString str=ui->pushButton_14->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_15_clicked()
{
    QString str=ui->pushButton_15->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_16_clicked()
{
    QString str=ui->pushButton_16->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_17_clicked()
{
    QString str=ui->pushButton_17->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_18_clicked()
{
    QString str=ui->pushButton_18->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_29_clicked()
{
    QString str=ui->pushButton_29->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_30_clicked()
{
    QString str=ui->pushButton_30->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_19_clicked()
{
    QString str=ui->pushButton_19->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_21_clicked()
{
    QString str=ui->pushButton_21->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_20_clicked()
{
    QString str=ui->pushButton_20->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_22_clicked()
{
    QString str=ui->pushButton_22->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_23_clicked()
{
    QString str=ui->pushButton_23->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_24_clicked()
{
    QString str=ui->pushButton_24->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_34_clicked()
{
    QString str=ui->pushButton_34->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_33_clicked()
{
    QString str=ui->pushButton_33->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_35_clicked()
{
    QString str=ui->pushButton_35->text();
    chepiaojiemian(str);
}



void Form::on_pushButton_36_clicked()
{
    QString str=ui->pushButton_36->text();
    chepiaojiemian(str);
}

7.formrengong.cpp

#include "form.h"
#include "ui_form.h"
#include 
#include 
//数组  字节数组头文件
#include 
#include 
#include 
//时间头文件   小时  分  秒
#include
//日期头文件  年  月  日
#include
#include 
//数据库头文件
#include 
#include 
//弹出消息框头文件
#include 
//数据库错误处理头文件
#include 
#include 
//数据库查询头文件
#include 
//数据参数绑定头文件
#include 
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
}

Form::~Form()
{
    delete ui;
}
int Form::zhaojiOK(int id1,QString zhangming,QString jinchu){
    int i=0;//循环变量
    for(i=0;ilineEdit->text().toInt();
    //QString str=ui->pushButton->text();
    //qDebug()< list1=str.split(",");
    //qDebug()<pushButton->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_2_clicked()
{
    QString str=ui->pushButton_2->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_4_clicked()
{
    QString str=ui->pushButton_4->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_6_clicked()
{
    QString str=ui->pushButton_6->text();
    chepiaojiemian(str);

}

void Form::on_pushButton_7_clicked()
{
    QString str=ui->pushButton_7->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_8_clicked()
{
    QString str=ui->pushButton_8->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_9_clicked()
{
    QString str=ui->pushButton_9->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_10_clicked()
{
    QString str=ui->pushButton_10->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_12_clicked()
{
    QString str=ui->pushButton_12->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_11_clicked()
{
    QString str=ui->pushButton_11->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_3_clicked()
{
    QString str=ui->pushButton_3->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_5_clicked()
{
    QString str=ui->pushButton_5->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_25_clicked()
{
    QString str=ui->pushButton_25->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_26_clicked()
{
    QString str=ui->pushButton_26->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_32_clicked()
{
    QString str=ui->pushButton_32->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_31_clicked()
{
    QString str=ui->pushButton_31->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_28_clicked()
{
    QString str=ui->pushButton_28->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_27_clicked()
{
    QString str=ui->pushButton_27->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_13_clicked()
{
    QString str=ui->pushButton_13->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_14_clicked()
{
    QString str=ui->pushButton_14->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_15_clicked()
{
    QString str=ui->pushButton_15->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_16_clicked()
{
    QString str=ui->pushButton_16->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_17_clicked()
{
    QString str=ui->pushButton_17->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_18_clicked()
{
    QString str=ui->pushButton_18->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_29_clicked()
{
    QString str=ui->pushButton_29->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_30_clicked()
{
    QString str=ui->pushButton_30->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_19_clicked()
{
    QString str=ui->pushButton_19->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_21_clicked()
{
    QString str=ui->pushButton_21->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_20_clicked()
{
    QString str=ui->pushButton_20->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_22_clicked()
{
    QString str=ui->pushButton_22->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_23_clicked()
{
    QString str=ui->pushButton_23->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_24_clicked()
{
    QString str=ui->pushButton_24->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_34_clicked()
{
    QString str=ui->pushButton_34->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_33_clicked()
{
    QString str=ui->pushButton_33->text();
    chepiaojiemian(str);
}

void Form::on_pushButton_35_clicked()
{
    QString str=ui->pushButton_35->text();
    chepiaojiemian(str);
}



void Form::on_pushButton_36_clicked()
{
    QString str=ui->pushButton_36->text();
    chepiaojiemian(str);
}

8.kaiguan.cpp

#include "kaiguan.h"

KaiGuan::KaiGuan()
{

}
int KaiGuan::cf=0;
int KaiGuan::dd=0;
int KaiGuan::start=0;
int KaiGuan::end=0;
QString KaiGuan::names[18]={"静安寺","南京西路","人民广场","南京东路","陆家嘴","东昌路","常熟路","陕西南路","新天地","老西门","大世界","黄陂南路","豫园","天潼路","国际客运中心","曲阜路","汉中路","长寿路"};
int KaiGuan::new_id=0;

9.main.cpp

#include "widget.h"
#include 
#include "form.h"
#include "formrengong.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    Form w2;
    w2.show();
    FormRenGong w3;
    w3.show();
    return a.exec();
}

10.messagew.cpp

#include "messagew.h"
#include 
MessageW::MessageW(QWidget *parent) : QWidget(parent)
{
    label.setParent(this);
    label.resize(700,100);
    label.move(20,10);
    QFont ft;
    ft.setPointSize(20);
    label.setFont(ft);
}

11.showchepiao.cpp

#include "showchepiao.h"

ShowChePiao::ShowChePiao(QWidget *parent) : QWidget(parent)
{
    label.setParent(this);
    label.resize(700,100);
    QFont ft;
    ft.setPointSize(20);
    label.setFont(ft);
    label.move(20,10);
}

12.widget.cpp

#include "widget.h"
#include "ui_widget.h"
#include 
#include 
#include 
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);  
}
Widget::~Widget()
{
    delete ui;
}
const int N=600;
void Widget::on_pushButton_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=0;
        chufa.label.setText("您确定从静安寺出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=0;
        daoda.label.setText("您确定到达静安寺?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_2_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=1;
        chufa.label.setText("您确定从南京西路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=1;
        daoda.label.setText("您确定到达南京西路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_3_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=2;
        chufa.label.setText("您确定从人民广场出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=2;
        daoda.label.setText("您确定到达人民广场?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_4_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=3;
        chufa.label.setText("您确定从南京东路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=3;
        daoda.label.setText("您确定到达南京东路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_5_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=4;
        chufa.label.setText("您确定从陆家嘴出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=4;
        daoda.label.setText("您确定到达陆家嘴?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_13_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=5;
        chufa.label.setText("您确定从东昌路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=5;
        daoda.label.setText("您确定到达东昌路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_15_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=17;
        chufa.label.setText("您确定从长寿路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=17;
        daoda.label.setText("您确定到达长寿路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_7_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=16;
        chufa.label.setText("您确定从汉中路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=16;
        daoda.label.setText("您确定到达汉中路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_6_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=15;
        chufa.label.setText("您确定从曲阜路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=15;
        daoda.label.setText("您确定到达曲阜路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_8_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=13;
        chufa.label.setText("您确定从天潼路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=13;
        daoda.label.setText("您确定到达天潼路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_16_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=14;
        chufa.label.setText("您确定从国际客运中心出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=14;
        daoda.label.setText("您确定到达国际客运中心?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_9_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=7;
        chufa.label.setText("您确定从陕西南路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=7;
        daoda.label.setText("您确定到达陕西南路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_14_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=9;
        chufa.label.setText("您确定从老西门出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=9;
        daoda.label.setText("您确定到达老西门?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_17_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=12;
        chufa.label.setText("您确定从豫园出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=12;
        daoda.label.setText("您确定到达豫园?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_10_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=11;
        chufa.label.setText("您确定从黄陂南路出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=11;
        daoda.label.setText("您确定到达黄陂南路?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_18_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=8;
        chufa.label.setText("您确定从新天地出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=8;
        daoda.label.setText("您确定到达新天地?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

void Widget::on_pushButton_11_clicked()
{
    if(KaiGuan::cf==0){
        KaiGuan::start=10;
        chufa.label.setText("您确定从大世界出发?");
        chufa.setFixedSize(N,300);//设置出发窗口固定宽高
        chufa.show();
    }
    else{
        KaiGuan::end=10;
        daoda.label.setText("您确定到达大世界?");
        daoda.setFixedSize(N,300);
        daoda.show();
    }
}

你可能感兴趣的:(项目,qt,ui,开发语言)