UI设计原型
代码
card.h`.
#ifndef CARD_H
#define CARD_H
#include<QString>
class card
{
public:
card();
void getcard(QString name1,QString number1,QString password1,QString telephone1);
void invest(double money1);
double moneyleft();
void pay(double p);
QString get_mycardnum();
QString get_name();
QString get_telephone();
void set_exsit_t();
bool get_exsit();
void set_exsit_f();
QString get_password();
void deletecard();
private:
QString name;
QString number;
QString password;
QString telephone;
double money;
bool exsit;
};
#endif // CARD_H
my_parkinglot.h
#ifndef MY_PARKINGLOT_H
#define MY_PARKINGLOT_H
#include <QWidget>
#include<QTime>
#include<parking_palce.h>
#include<QTableWidget>
#include<QWidget>
#include<QInputDialog>
#include<card.h>
#include<QMessageBox>
namespace Ui {
class my_parkinglot;
}
class my_parkinglot : public QWidget
{
Q_OBJECT
public:
explicit my_parkinglot(QWidget *parent = 0);
~my_parkinglot();
private slots:
void on_parking_clicked();
void on_pick_up_clicked();
void on_search_car_clicked();
void on_pushButton_clicked();
void on_sign_up_clicked();
void on_pushButton_3_clicked();
void on_pushButton_2_clicked();
private:
Ui::my_parkinglot *ui;
parking_palce common_p[20];
parking_palce chuzu[20];
card cardsystem[100];
};
#endif // MY_PARKINGLOT_H
mypushbutton.h
#ifndef MYPUSHBUTTON_H
#define MYPUSHBUTTON_H
#include <QPushButton>
class mypushbutton : public QPushButton
{
Q_OBJECT
public:
explicit mypushbutton(QWidget *parent = nullptr);
mypushbutton(QString normalimg,QString pressimg = "");
QString normalimgpath;
QString pressimgpath;
signals:
public slots:
};
#endif // MYPUSHBUTTON_H
parking_place.h
#include<QString>
#include<QTime>
#include<card.h>
class parking_palce
{
public:
parking_palce();
parking_palce(QString);
void setinformation(QString carname,QString cartype);
void set_state_empty();
void set_state_using();
void set_time();
int get_timegap();
void sign_in_card(card card1);
void have_card();
void no_card();
bool get_ca();
void pay_by_card(double p);
double get_moneyleft();
void deletecard();
QString get_cardnumber();
void set_card_i(int i);
int get_card_i();
private:
QString name;//用户姓名
QString car_id;//车牌号
QString car_type;//车类型
QTime start_time;//开始时间
QTime end_time;
bool is_using; // 是否使用
card mycard; //停车使用的卡号
bool have_ca;//是否使用了会员卡
int card_i; //卡在carsyste中的顺序
};
#endif // PARKING_PALCE_H
card.cpp
#include "card.h"
card::card()
{
exsit == false;
}
void card::getcard(QString name1, QString number1, QString password1, QString telephone1)
{
name = name1;
number = number1;
password = password1;
telephone = telephone1;
money = 50;
}
void card::invest(double money1)
{
money+=money1;
}
double card::moneyleft()
{
return money;
}
void card::pay(double p)
{
money -=p;
}
QString card::get_mycardnum()
{
return number;
}
QString card::get_name()
{
return name;
}
QString card::get_telephone()
{
return telephone;
}
void card::set_exsit_f()
{
exsit = false;
}
void card::set_exsit_t()
{
exsit = true;
}
bool card::get_exsit()
{
return exsit;
}
QString card::get_password()
{
return password;
}
void card::deletecard()
{
name =nullptr;
telephone = nullptr;
number = nullptr;
money =0;
password = nullptr;
}
main.cpp
#include "my_parkinglot.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
my_parkinglot w;
w.show();
return a.exec();
}
my_parkinglot.cpp
#include "my_parkinglot.h"
#include "ui_my_parkinglot.h"
#include<mypushbutton.h>
#define prize_per_sec 0.0005
my_parkinglot::my_parkinglot(QWidget *parent) :
QWidget(parent),
ui(new Ui::my_parkinglot)
{
ui->setupUi(this);
for(int i=0;i<20;i++)
{
common_p[i] = parking_palce(QString("车位-%1").arg(QString::number(i+1))); //初始化车位名
ui->common_lot->setItem(i,0,new QTableWidgetItem(QString("车位-%1").arg(QString::number(i+1))));// 初始化车位
ui->common_lot->setItem(i,1,new QTableWidgetItem("empty")); //车位状态初始化
ui-