当前位置: 首页 > news >正文

工信部个人备案网站可信吗东莞企业营销型网站

工信部个人备案网站可信吗,东莞企业营销型网站,挖掘企业构思的途径,wordpress改为中文版目录功能结构adClient.promain.cppadclient.h 客户端adclient.cpp 客户端addate.h 时间处理addate.cpp 时间处理adsocket.h 客户端Socket处理adsocket.cpp 客户端Socket处理weather.h 天气信息处理weather.cpp 天气信息处理rollmassege.h 滚动信息处理rollmassege.cpp 滚动信息… 目录功能结构adClient.promain.cppadclient.h 客户端adclient.cpp 客户端addate.h 时间处理addate.cpp 时间处理adsocket.h 客户端Socket处理adsocket.cpp 客户端Socket处理weather.h 天气信息处理weather.cpp 天气信息处理rollmassege.h 滚动信息处理rollmassege.cpp 滚动信息处理效果功能 连接服务器上位机广告图片播放模块日期显示模块天气显示模块信息提示模块 结构 adClient.pro QT core gui networkgreaterThan(QT_MAJOR_VERSION, 4): QT widgetsCONFIG c11TARGET adClient TEMPLATE appSOURCES main.cpp\adclient.cpp \addate.cpp \adsocket.cpp \weather.cpp \rollmassege.cppHEADERS adclient.h \addate.h \adsocket.h \tcp_MSG.h \weather.h \rollmassege.hFORMS adclient.uiRESOURCES \res.qrcmain.cpp #include adclient.h #include QApplication #include QDebug #include QDir int main(int argc, char *argv[]) {QApplication a(argc, argv);// 判断当前运行环境是否为Linux或Windows。 #ifdef Q_OS_LINUXqDebug() Current OS is Linux; #elif defined(Q_OS_WIN)qDebug() Current OS is Windows; #elseqDebug() Unknown OS; #endifQString folderName pic;//QString folderPath QDir::currentPath() / folderName;QString folderPath QApplication::applicationDirPath() / folderName;QDir folder(folderPath);if (!folder.exists()){bool success folder.mkpath(.); // 创建文件夹if (success)qDebug() 文件夹创建成功;elseqDebug() 文件夹创建失败;}elseqDebug() 文件夹已存在;QDir::setCurrent(folderPath);// 设置文件生成路径AdClient w;w.show();return a.exec(); }adclient.h 客户端 #ifndef ADCLIENT_H #define ADCLIENT_H#include QMainWindow #include addate.h #include adsocket.h #include weather.h #include rollmassege.h #include QLabel #include QProgressDialog #include stdlib.h #include QThread #include QTimer #include QFile #include QMessageBox #include QNetworkInterface #include QTcpSocket #include QHostAddress #include QAbstractSocket #include QLineEdit #include QPushButtonnamespace Ui { class AdClient; }class AdClient : public QMainWindow {Q_OBJECTpublic:explicit AdClient(QWidget *parent 0);~AdClient();void saveFile();// 保存文件void InitStatusBar();// 初始化底部状态栏QString GetLocalIP();// 获取本地IPpublic slots:void showImage(QImage);// 图片显示void showProgressBar(int currentProgress,int finish);//进度条显示void autoPlayTimeOut();//自动播放void GUI_WarningMsg(QString title,QString text,QString buttons,QString defaultButton);//设置警报void connectToServer();// 链接到服务器 private:Ui::AdClient *ui;AdDate *date;AdSocket *socket;Weather *weater;RollMassege *rollmsg;QProgressDialog *progress;// 创建进度条QTimer autoPlayTimer;int index;QLabel *mLocalIP;QLabel *serverIP_lb;QLineEdit *serverIP;QLabel *serverPort_lb;QLineEdit *serverPort;QPushButton *connectTcp;};#endif // ADCLIENT_Hadclient.cpp 客户端 #include adclient.h #include ui_adclient.h #include QDebugQMapQString,QImage qMapPicturePath;// 图片路径//QTcpSocket 的默认缓存区大小是 64KB65536字节 AdClient::AdClient(QWidget *parent) :QMainWindow(parent),ui(new Ui::AdClient) {ui-setupUi(this);this-setWindowIcon(QIcon(:/client.jpg));date new AdDate(ui-date_lb);//时间socket new AdSocket;// TCP客户端weater new Weather(ui-weather_lb);// 接收天气信息绘制rollmsg new RollMassege(ui-msg_lb, ui-msg_lb);// 滚动信息connect(socket, SIGNAL(sig_showWeather(QString,QString,QString)), weater, SLOT(showWeather(QString,QString,QString)));connect(socket, SIGNAL(sig_showTxt(QString)), rollmsg, SLOT(showTxt(QString)));connect(socket, SIGNAL(sig_showImage(QImage)), this, SLOT(showImage(QImage)));connect(socket, SIGNAL(sig_showProgressBar(int,int)), this, SLOT(showProgressBar(int,int)),Qt::QueuedConnection);connect(socket, SIGNAL(GUI_WarningSignal(QString,QString,QString,QString)), this, SLOT(GUI_WarningMsg(QString,QString,QString,QString)));date-start();//更新时间progress nullptr;autoPlayTimer.stop();connect(autoPlayTimer, SIGNAL(timeout()), this, SLOT(autoPlayTimeOut()));InitStatusBar();// 初始化底部状态栏 }AdClient::~AdClient() {delete socket;delete ui; }// 保存文件 void AdClient::saveFile() {QString fileNameqMapPicturePath.lastKey();qDebug()lastKeyfileName;QImage imageqMapPicturePath.last();image.save(fileName); }// 初始化底部状态栏 void AdClient::InitStatusBar() {mLocalIPnew QLabel(this);mLocalIP-setMinimumWidth(230);QString ip GetLocalIP();// mLocalIP-setText(本地IP:ip);mLocalIP-setText(本地IP:tr(font color\red\%1/font).arg(ip));serverIP_lbnew QLabel(this);serverIP_lb-setMinimumWidth(100);serverIP_lb-setText(服务器IP:);serverIPnew QLineEdit(this);serverIP-setMinimumWidth(200);serverIP-setInputMask(000.000.000.000);serverPort_lbnew QLabel(this);serverPort_lb-setMinimumWidth(60);serverPort_lb-setText(Port:);serverPortnew QLineEdit(this);serverPort-setMinimumWidth(60);serverPort-setPlaceholderText(8888);connectTcpnew QPushButton(链接,this);connectTcp-setMinimumWidth(100);ui-statusBar-addWidget(mLocalIP);ui-statusBar-addWidget(serverIP_lb);ui-statusBar-addWidget(serverIP);ui-statusBar-addWidget(serverPort_lb);ui-statusBar-addWidget(serverPort);ui-statusBar-addWidget(connectTcp);connect(connectTcp, SIGNAL(clicked()), this, SLOT(connectToServer())); }// 获取本地IP QString AdClient::GetLocalIP() {QListQHostAddress listQNetworkInterface::allAddresses();foreach(QHostAddress address,list){if(address.protocol()QAbstractSocket::IPv4Protocol){qDebug()address.toString();return address.toString();}}return ; }// 图片显示 void AdClient::showImage(QImage image) {qDebug()显示图片__LINE__;QPixmap pixmapQPixmap::fromImage(image);// 内容是否自动缩放参数true自动缩放ui-video_lb-setScaledContents(true);//显示图片的全部// 将图片缩放到指定大小参数ui-label-size()表示缩放的大小Qt::KeepAspectRatio表示保持图片的宽高比Qt::SmoothTransformation表示使用平滑缩放算法ui-video_lb-setPixmap(pixmap.scaled(ui-video_lb-size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));qDebug()图片数量qMapPicturePath.count();qDebug()定时器状态autoPlayTimer.isActive();if(qMapPicturePath.count()2){if(!autoPlayTimer.isActive()){// 两张以上图片开启播放autoPlayTimer.start(5000);index0;}}else{autoPlayTimer.stop();}if(qMapPicturePath.count()1){// 功能没问题调试注释避免多次保存//saveFile();// 保存文件} }//进度条显示 void AdClient::showProgressBar(int currentProgress, int finish) {qDebug()进度条显示__LINE__;if (!progress){//创建进度条progress new QProgressDialog(接收中...., 取消, 0, 100, this);progress-setWindowModality(Qt::WindowModal);progress-setFixedSize(this-width()*0.3,this-height()*0.3);progress-setVisible(true);}//usleep(500);//在Windows环境下已被弃用QThread::msleep(50);//休眠50毫秒//更新进度条progress-setValue(currentProgress * 100 / finish);//如果任务已经完成隐藏进度条if (currentProgress finish){qDebug()进度条显示完成__LINE__;progress-hide();delete progress;progress nullptr;} }//自动播放 void AdClient::autoPlayTimeOut() {QListQString keyList qMapPicturePath.keys();//存放的就是QMap的key值if(indexqMapPicturePath.count())// 删除广告时有可能 index0;QImage imageqMapPicturePath.value(keyList.at(index));qDebug()自动播放:keyList.at(index);showImage(image);index; } //设置警报 void AdClient::GUI_WarningMsg(QString title, QString text, QString buttons, QString defaultButton) {Q_UNUSED(buttons)//忽略编译器发出的警告表明变量event未使用Q_UNUSED(defaultButton)QMessageBox *boxnew QMessageBox(QMessageBox::Warning,title,text,QMessageBox::Cancel,this);QTimer::singleShot(5000,this,[](){if(!box-isHidden()box-isVisible()){box-accept();}});// 5s后必执行box-exec();return; }// 链接到服务器 void AdClient::connectToServer() {if(serverIP-text().isEmpty()||serverPort-text().isEmpty()){QMessageBox::warning(this,提示,请输入IP或Port);return;}socket-idGetLocalIP();socket-addressserverIP-text();qDebug()服务器IP:socket-address;socket-portserverPort-text().toInt();qDebug()服务器Port:socket-port;qDebug()是否已经连接:socket-isValid();if(socket-isValid())// 如果套接字有效并且可以使用则返回true;否则返回false。{socket-disconnectFromHost();// 与服务器断开连接// 无需再手动连接只要更新IP和Port就行AdSocket::conAgain会重新发起连接.}else{socket-connectToHost(QHostAddress(socket-address), socket-port);}qDebug()是否已经连接:socket-isValid(); }addate.h 时间处理 #ifndef ADDATE_H #define ADDATE_H#include QTime #include QDate #include QLabel #include QTimerclass AdDate : public QObject {Q_OBJECT public:AdDate(QLabel *_mlabel, QObject *parent 0);~AdDate();void start();// 定时器开启 public slots:void updateTime();// 定时器1s超时执行一次 private:QLabel *mlabel;QTimer *mtimer; };#endif // ADDATE_Haddate.cpp 时间处理 #include addate.hAdDate::AdDate(QLabel *_mlabel, QObject *parent):QObject(parent) {mlabel _mlabel;mtimer new QTimer;connect(mtimer, SIGNAL(timeout()), this, SLOT(updateTime())); }AdDate::~AdDate() {delete mtimer; }void AdDate::start() {mtimer-start(1000); }void AdDate::updateTime() {QString time QTime::currentTime().toString(hh:mm:ss)\nQDate::currentDate().toString(yy/MM/dd ddd);mlabel-setText(time); }adsocket.h 客户端Socket处理 #ifndef ADSOCKET_H #define ADSOCKET_H#include QTcpSocket #include QHostAddress #include QAbstractSocket #include QAbstractSocket #include QImage #include QLabel #include QBuffer #include QTime #include string.h #include tcp_MSG.hclass AdSocket : public QTcpSocket {Q_OBJECT public:explicit AdSocket(QObject *parent 0);~AdSocket();QString id;QString address;int port;int readMsgType;signals:void sig_showWeather(QString city,QString area,QString wt);// 发送天气信息void sig_showTxt(QString tcp_Txt);// 发送文字信息void sig_showImage(QImage tcp_image);// 发送文字信息void sig_showProgressBar(int currentProgress, int finish);// 发送进度条信息void GUI_WarningSignal(QString title,QString text,QString buttons,QString defaultButton);//设置警报public slots:void readMsg();// 接收信息void conSuc(); // 成功建立连接void conAgain();// 重新连接void conAgain(QAbstractSocket::SocketError);// 重新连接private:int needFileSize;int currentReceiveSize;QByteArray currentReceiveByte;int milsec;QString fileName; };#endif // ADSOCKET_H adsocket.cpp 客户端Socket处理 #include adsocket.h #include QDebugextern QMapQString,QImage qMapPicturePath;// 图片路径// QTcpSocket会自动处理大小端问题 AdSocket::AdSocket(QObject *parent) :QTcpSocket(parent) {//注册tcp_MSG类型qRegisterMetaTypetcp_MSG(tcp_MSG);id 0011;/* 每当有新的输入数据时就会发出这个信号。请记住新传入的数据只报告一次;如果您不读取所有数据这个类会缓冲数据您可以稍后读取它但是除非新数据到达否则不会发出信号。*/connect(this, SIGNAL(readyRead()),this, SLOT(readMsg()));//该信号在调用connectToHost()并成功建立连接之后发出。connect(this, SIGNAL(connected()),this, SLOT(conSuc()));// 该信号在套接字断开连接时发出connect(this, SIGNAL(disconnected()),this, SLOT(conAgain()));address127.0.0.1;port8888;//connectToHost(QHostAddress(address), port);// 默认连接127.0.0.1 8888//该信号在错误发生后发出。socketError参数描述发生错误的类型connect(this, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(conAgain(QAbstractSocket::SocketError)));readMsgTypeMsgType::Init;milsec0; }AdSocket::~AdSocket() {}// 接收信息 void AdSocket::readMsg() {//读取缓冲区数据QByteArray buffer readAll();qDebug()进来了__LINE__;if(readMsgTypeMsgType::Init){tcp_MSG *msg(tcp_MSG *)buffer.data(); //强转为结构体需要用结构体指针接收qDebug()进来了__LINE__;qDebug()类型msg-type;switch (msg-type){case WEATHER://天气{QString citymsg-city;QString areamsg-area;QString weathermsg-weather;//weather\t\tcity\tarea\nweather;emit sig_showWeather(city,area,weather);// 发送天气信息break;}case MASSEGE:// 留言{QString tcp_Txtmsg-txt;qDebug()文字信息tcp_Txt;emit sig_showTxt(tcp_Txt);// 发送文字信息break;}case VIDEO:// 视频qDebug()发送视频信息;break;case AD_add://添加广告{qDebug()添加广告__LINE__;qDebug()文件名 QString(msg-fileName);qDebug()编号 msg-index;qDebug()总数 msg-allAd_Num;needFileSizemsg-fileSize;currentReceiveSize0;currentReceiveByte.clear();QByteArray sendTcpData;//使用字节数组,将结构体转为字符数组发送的是字符数组数据在传输过程中都是byte类型的//直接sizeofsenddata内存会变小设置了对齐方式解决sendTcpData.resize(sizeof(tcp_backMSG));tcp_backMSG backMsg{};strcpy(backMsg.id,id.toUtf8().data());backMsg.state1;backMsg.typeMsgType::Write_back;//将封装好的结构体转为QByteArray数组因为传输都是Byte类型memcpy(sendTcpData.data(),backMsg,sizeof(tcp_backMSG));this-write(sendTcpData);// 回复fileName.clear();fileNameQString(msg-fileName);readMsgTypeMsgType::AD_add;break;}case AD_delete://删除广告{qDebug()删除广告__LINE__;qDebug()文件名 QString(msg-fileName);int success qMapPicturePath.remove(QString(msg-fileName));if(success){if(qMapPicturePath.count()1){// 有图片emit sig_showImage(qMapPicturePath.first());}else{// 没有图片QImage image(100, 100, QImage::Format_RGBA8888);image.fill(QColor(0, 0, 0, 0));// 纯透明图片emit sig_showImage(image);}emit GUI_WarningSignal(提示,删除广告成功,NULL,NULL);}else{emit GUI_WarningSignal(提示,删除广告失败,NULL,NULL);}break;}default:qDebug();break;}}else if(readMsgTypeMsgType::AD_add){qDebug()添加广告__LINE__;qDebug()需要接收大小needFileSize;// 记录开始时间QTime startTime QTime::currentTime();currentReceiveSizebuffer.size();currentReceiveBytebuffer;qDebug()当前接收大小currentReceiveSize;emit sig_showProgressBar(currentReceiveSize,needFileSize);// 记录结束时间QTime endTime QTime::currentTime();// 计算运行时间milsec startTime.msecsTo(endTime);if(needFileSizecurrentReceiveSize){qDebug()图片接收完成;startTime QTime::currentTime();QByteArray Ret_bytearray QByteArray::fromBase64(currentReceiveByte);QBuffer buffer(Ret_bytearray);buffer.open(QIODevice::WriteOnly);QPixmap imageresult;imageresult.loadFromData(Ret_bytearray);qMapPicturePath.insert(fileName,imageresult.toImage());// 先插入键值emit sig_showImage(imageresult.toImage());readMsgTypeMsgType::Init;endTime QTime::currentTime();milsec startTime.msecsTo(endTime);qDebug()接收消耗时间milsec毫秒;}} } // 成功建立连接 void AdSocket::conSuc() {QByteArray sendTcpData;//使用字节数组,将结构体转为字符数组发送的是字符数组数据在传输过程中都是byte类型的//直接sizeofsenddata内存会变小设置了对齐方式解决sendTcpData.resize(sizeof(tcp_backMSG));tcp_backMSG msg{};strcpy(msg.id,id.toUtf8().data());msg.state0;msg.typeMsgType::Init;//将封装好的结构体转为QByteArray数组因为传输都是Byte类型memcpy(sendTcpData.data(),msg,sizeof(tcp_backMSG));this-write(sendTcpData);qDebug()connect success; }// 重新连接 void AdSocket::conAgain() {qDebug()套接字断开连接时重新连接;abort();// 终止当前连接并重置套接字connectToHost(QHostAddress(address), port); } // 重新连接 void AdSocket::conAgain(QAbstractSocket::SocketError error) {qDebug()连接失败:error;readMsgTypeMsgType::Init;abort();// 终止当前连接并重置套接字if(errorQAbstractSocket::ConnectionRefusedError){connectToHost(QHostAddress(address), port);} }weather.h 天气信息处理 #ifndef WEATHER_H #define WEATHER_H#include QObject #include QLabel #include QDebug class Weather : public QObject {Q_OBJECT public:explicit Weather( QLabel *_label,QObject *parent 0);signals:public slots:void showWeather(QString city,QString area,QString weather);private:QLabel *label;QString _city;QString _area; };#endif // WEATHER_Hweather.cpp 天气信息处理 #include weather.hWeather::Weather( QLabel *_label, QObject *parent) :QObject(parent) {label _label; }void Weather::showWeather(QString city,QString area,QString weather) {_citycity;qDebug()城市_city;_areaarea;qDebug()地区_area;weather\t\t_city\t_area\n\tweather;label-setText(weather); } rollmassege.h 滚动信息处理 #ifndef ROLLMASSEGE_H #define ROLLMASSEGE_H#include QLabel #include QEvent #include QTimer #include QRect #include QPainter #include QFontclass RollMassege : public QLabel {Q_OBJECT public:explicit RollMassege(QWidget *parent 0);explicit RollMassege(QLabel *_label, QWidget *parent 0);void paintEvent(QPaintEvent *event); signals:public slots:void updateMsg();void showTxt(QString tcp_Txt); private:QString txt;QRect rect;int offset;//偏移量QTimer *timer; };#endif // ROLLMASSEGE_H rollmassege.cpp 滚动信息处理 #include rollmassege.h #include QDebugRollMassege::RollMassege(QWidget *parent) :QLabel(parent) { }RollMassege::RollMassege(QLabel *_label, QWidget *parent) :QLabel(parent) {rect _label-geometry();rect.setWidth(798);rect.setHeight(80);setGeometry(rect);show();qDebug()rect.width() rect.height();offset rect.width();//偏移量txt 暂无信息;timer new QTimer;connect(timer, SIGNAL(timeout()), this, SLOT(updateMsg()));timer-start(50); } // 绘画事件 void RollMassege::paintEvent(QPaintEvent *event) {Q_UNUSED(event); //忽略编译器发出的警告表明变量event未使用QPainter painter(this);QFont font;font.setPointSize(16);painter.setFont(font);painter.drawText(rect.x()offset, rect.y()30, txt);// 绘制文字,x偏移量 }void RollMassege::updateMsg() {offset--;if(offset0) offset rect.width();update();// 刷新触发绘画事件paintEvent }void RollMassege::showTxt(QString tcp_Txt) {txt tcp_Txt;update(); } 效果
http://www.w-s-a.com/news/23501/

相关文章:

  • 网站开发设置网页端口申请免费个人网站空间
  • 制作广告网站的步骤云服务器做网站
  • ipv6可以做网站吗东莞网站建站推广
  • 注册功能的网站怎么做做网站容易还是编程容易
  • wordpress建立目录seo编辑培训
  • 网站怎么群发广州现在可以正常出入吗
  • 微信有网站开发吗多语种网站
  • 深圳网站设计 建设首选深圳市室内设计公司排名前50
  • 上海网站建设 觉策动力wordpress接口开发
  • 网站建设服务器的选择方案小型视频网站建设
  • 江宁做网站价格扬州立扬计算机培训网站建设怎么样
  • 手表网站背景开发新客户的十大渠道
  • 定制网站设计wordpress写的网站
  • p2p网站建设公司排名成都装饰公司
  • 网站被k怎么恢复wordpress缓存类
  • 做外贸有哪些网站平台最近文章 wordpress
  • joomla网站模板一个人做网站的swot
  • 南京建设网站需要多少钱深圳专业网站建设制作价格
  • 天河建网站装修公司线上推广方式
  • 超市网站怎么做的目前最流行的拓客方法
  • 做文字logo的网站贵阳商城网站开发
  • 沧州有没有做网站的中国建筑设计
  • 建设网站 系统占用空间在线代理浏览网站
  • 做海报有什么参考的网站网站建设验收合同
  • 酒店网站制作wordpress文章评论设置
  • 造一个官方网站wordpress mysql类
  • 怎么做卡商网站河南做网站找谁
  • 网站建设招标方案模板上线啦 图谱智能网站
  • 龙口网站建设公司哪家好wordpress 上传类型
  • 做外贸主要看什么网站服务平台的宗旨