资源简介

1、可通过自定义协议控制信号灯,实时显示及关闭 2、可修改定时器为线程运行,减少资源消耗 3、QT5编写,可跨平台交叉编译,带有实际贴图文件中,可避免自己再次寻找贴图,适合初学者,资源图丰富

资源截图

代码片段和文件信息

#include “dialog.h“
#include “ui_dialog.h“
#include “./hiteTraffic/widget.h“
#include 
#include 

Dialog::Dialog(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    ui->pushButton->setText(“开启实时显示“);

    w = new Widget;
    dialogtimer = new QTimer(this);//转接子ui定时器
    dialogtimer = w->timer;
    connect(ui->pushButtonSIGNAL(clicked())thisSLOT(real_time_start()));
    ui->stackedWidget->addWidget(w);//往栈窗口添加对话框界面

}

Dialog::~Dialog()
{
    delete ui;
}

//开启实时显示
void Dialog::real_time_start()
{
    if(ui->pushButton->text() == “开启实时显示“)
    {
        w->show();
        dialogtimer->start();//定时器开启
        ui->pushButton->setText(“关闭实时显示“);
    }
//    connect(ui->pushButtonSIGNAL(clicked())thisSLOT(deleteLater()));
    disconnect(ui->pushButtonSIGNAL(clicked())thisSLOT(real_time_start()));
    connect(ui->pushButtonSIGNAL(clicked())thisSLOT(real_time_stop()));
}

//关闭实时显示
void Dialog::real_time_stop()
{
    if(ui->pushButton->text() == “关闭实时显示“)
    {
        //w->close();
        w->Ui_init();//隐藏信号灯
        dialogtimer->stop();//定时器停止
        ui->pushButton->setText(“开启实时显示“);
    }
//    connect(ui->pushButtonSIGNAL(clicked())thisSLOT(deleteLater()));
    disconnect(ui->pushButtonSIGNAL(clicked())thisSLOT(real_time_stop()));
    connect(ui->pushButtonSIGNAL(clicked())thisSLOT(real_time_start()));
}

评论

共有 条评论