You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
#include "number_of_car.h"
|
|
#include "ui_number_of_car.h"
|
|
#include <QSqlQuery>
|
|
#include <QNetworkRequest>
|
|
#include <QDebug>
|
|
#include <QMessageBox>
|
|
#include <QMovie> // 包含QMovie的头文件
|
|
|
|
number_of_car::number_of_car(QWidget *parent) : QDialog(parent),
|
|
ui(new Ui::number_of_car)
|
|
{
|
|
ui->setupUi(this);
|
|
this->setWindowTitle("车场信息");
|
|
|
|
//动图
|
|
QMovie *movie = new QMovie(":/car.png");
|
|
ui->label_3->setMovie(movie);
|
|
movie->start();
|
|
|
|
this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
|
|
|
|
}
|
|
|
|
number_of_car::~number_of_car()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void number_of_car::on_pushButton_clicked()
|
|
{
|
|
this->close();
|
|
}
|
|
|
|
void number_of_car::cnt_slot()
|
|
{
|
|
|
|
// 使用在 main 中创建的数据库连接,获取当前车场内车辆数
|
|
QSqlDatabase db = QSqlDatabase::database("text01");
|
|
|
|
if (!db.isOpen()) {
|
|
QMessageBox::warning(this, tr("警告!"), tr("数据库未打开!"), QMessageBox::Yes);
|
|
return;
|
|
}
|
|
|
|
QString str = QString("select * from cnt where number='%1' ").arg("number_of_c");
|
|
QSqlQuery query(db);
|
|
query.exec(str);
|
|
query.next();
|
|
int cnt = query.value(1).toInt();
|
|
QString cnt_str_1 = QString::number(cnt);
|
|
QString cnt_str_2 = QString::number(100 - cnt);
|
|
// 显示信息
|
|
ui->textBrowser->setText(cnt_str_1);
|
|
ui->textBrowser_2->setText(cnt_str_2);
|
|
}
|