国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

政府網(wǎng)站建設(shè)公司 政務(wù)qq推廣引流網(wǎng)站

政府網(wǎng)站建設(shè)公司 政務(wù),qq推廣引流網(wǎng)站,有什么檢索標準的網(wǎng)站,鄭州公司做網(wǎng)站漢獅說明:復(fù)現(xiàn)的代碼來自《Qt C6.0》P496-P500。在復(fù)現(xiàn)時完全按照代碼,出現(xiàn)了兩處報錯: (1)ui指針(2)按鈕的響應(yīng)函數(shù)。下面程序?qū)σ陨蠁栴}進行了修改。除了圖片、清空、關(guān)閉功能外,其他…

說明:復(fù)現(xiàn)的代碼來自《Qt C++6.0》P496-P500。在復(fù)現(xiàn)時完全按照代碼,出現(xiàn)了兩處報錯:

(1)ui指針(2)按鈕的響應(yīng)函數(shù)。下面程序?qū)σ陨蠁栴}進行了修改。除了圖片、清空、關(guān)閉功能外,其他功能實現(xiàn)復(fù)現(xiàn)。


主線程:

.h文件

#pragma once#include <QtWidgets/QMainWindow>
#include "ui_ThreadTest_one.h"
#include "QtClass.h"class ThreadTest_one : public QMainWindow//主線程
{Q_OBJECTprivate:QtClass* threadA;protected:void closeEvent(QCloseEvent* event);public:ThreadTest_one(QWidget* parent = nullptr);~ThreadTest_one();private:Ui::ThreadTest_oneClass ui;public slots:void do_threadA_started();void do_threadA_finished();void do_threadA_newValue(int seq, int diceValue);void on_actThread_Run_clicked();void on_actDice_Run_clicked();void on_actThread_Quit_clicked();void on_actDict_Pause_clicked();
};

.cpp文件

#include "ThreadTest_one.h"
#include <QCloseEvent>
#include <QThread>ThreadTest_one::ThreadTest_one(QWidget *parent): QMainWindow(parent)
{ui.setupUi(this);threadA = new QtClass(this);//創(chuàng)建工作線程connect(threadA, &QtClass::started, this, &ThreadTest_one::do_threadA_started);connect(threadA, &QtClass::finished, this, &ThreadTest_one::do_threadA_finished);connect(threadA, &QtClass::newValue, this, &ThreadTest_one::do_threadA_newValue);
}void ThreadTest_one::do_threadA_started() {ui.statusBar->showMessage("Thread狀態(tài):thread start");ui.actThread_Run->setEnabled(false);ui.actThread_Quit->setEnabled(true);ui.actDice_Run->setEnabled(true);}
void ThreadTest_one::do_threadA_finished() {ui.statusBar->showMessage("Thread狀態(tài):thread finished");ui.actThread_Run->setEnabled(true);ui.actThread_Quit->setEnabled(false);ui.actDice_Run->setEnabled(false);ui.actDict_Pause->setEnabled(false);
}void ThreadTest_one::do_threadA_newValue(int seq, int diceValue) {//與線程的newValue()信號相關(guān)聯(lián)QString str = QString::asprintf("第%d次投骰子,點數(shù)為%d", seq, diceValue);ui.plainTextEdit->appendPlainText(str);}//按鍵的槽函數(shù)
void ThreadTest_one::on_actThread_Run_clicked() {//要用clicked才能得到響應(yīng)threadA->start();
}
void ThreadTest_one::on_actThread_Quit_clicked() {threadA->stopThread();
}
void ThreadTest_one::on_actDice_Run_clicked() {threadA->diceBegin();ui.actDice_Run->setEnabled(false);ui.actDict_Pause->setEnabled(true);
}
void ThreadTest_one::on_actDict_Pause_clicked() {threadA->dicePause();ui.actThread_Run->setEnabled(true);ui.actDict_Pause->setEnabled(false);
}//重定義事件處理函數(shù),確保窗口關(guān)閉時線程被停止
void ThreadTest_one::closeEvent(QCloseEvent* event) {if (threadA->isRunning()) {threadA->terminate();threadA->wait();}event->accept();
}ThreadTest_one::~ThreadTest_one()
{}

工作線程:

.h文件

#pragma once#include <QThread>class QtClass  : public QThread
{Q_OBJECTpublic:QtClass(QObject *parent);~QtClass();
private:int m_seq = 0;   //擲骰子次數(shù)的序號int m_diceValue;//骰子的點數(shù)bool m_paused = true;//暫停投骰子bool m_stop = false;//停止線程protected:void run();//線程的任務(wù)public:void diceBegin();//開始擲骰子void dicePause();//暫停投骰子void stopThread();//停止線程signals:void newValue(int seq, int diceValue);//產(chǎn)生新點數(shù)的信號};

.cpp文件

#include "QtClass.h"
#include<QRandomGenerator>
#include<QThread>QtClass::QtClass(QObject *parent): QThread(parent)
{}
void QtClass::diceBegin() {//開始擲骰子m_paused = false;
}
void QtClass::dicePause() {//停止擲骰子m_paused = true;
}
void QtClass::stopThread() {//停止線程m_stop = true;
}
void QtClass::run() {//run函數(shù)處理事件循環(huán)m_stop = false;m_paused = true;m_seq = 0;while (!m_stop) {if (!m_paused) {m_diceValue = QRandomGenerator::global()->bounded(1, 7);m_seq++;emit newValue(m_seq, m_diceValue);}msleep(500);}quit();//退出線程
}
QtClass::~QtClass()
{}

http://aloenet.com.cn/news/30797.html

相關(guān)文章:

  • 境外公司注冊優(yōu)化工具箱下載
  • 做圖網(wǎng)站有哪些線上網(wǎng)絡(luò)推廣怎么做
  • 導(dǎo)航欄網(wǎng)站模板特效搭建一個網(wǎng)站的流程
  • 中國企業(yè)培訓(xùn)網(wǎng)蘭州seo培訓(xùn)
  • 如何建設(shè)網(wǎng)站山東濟南興田德潤官網(wǎng)域名檢測工具
  • 俄語網(wǎng)站建設(shè)公司沒經(jīng)驗可以做電商運營嗎
  • 模仿京東商城網(wǎng)站開發(fā)視頻蘋果自研搜索引擎或為替代谷歌
  • 免抵退稅在哪個網(wǎng)站做北京新聞最新消息
  • 電商網(wǎng)站建設(shè)與運營seo專員工作容易學(xué)嗎
  • 順德新網(wǎng)站制作行業(yè)關(guān)鍵詞一覽表
  • 個人網(wǎng)站如何做專業(yè)的營銷團隊哪里找
  • 廣州做網(wǎng)站哪家好網(wǎng)站推廣怎么做有效果
  • 網(wǎng)站公安備案網(wǎng)址電商平臺怎么加入
  • 凡科免費建設(shè)企業(yè)網(wǎng)站靠譜嗎個人做外貿(mào)怎樣起步
  • 電子商務(wù)網(wǎng)站建設(shè)花費今日新聞頭條新聞最新
  • 泗陽城鄉(xiāng)建設(shè)局網(wǎng)站域名seo查詢
  • 百度優(yōu)化網(wǎng)站建設(shè)wordpress外貿(mào)獨立站
  • 網(wǎng)站維護需要會什么海外免費網(wǎng)站推廣
  • 網(wǎng)站建設(shè)中代碼怎么自己做網(wǎng)頁
  • 網(wǎng)站設(shè)計與管理邯鄲百度推廣公司
  • 哪里有國內(nèi)網(wǎng)站建設(shè)公司淄博網(wǎng)站制作
  • 網(wǎng)站建站公司排名優(yōu)化網(wǎng)站的公司哪家好
  • 日照網(wǎng)站建設(shè)千萬別在百度上搜別人名字
  • 杭州灣新區(qū)建設(shè)局網(wǎng)站seo優(yōu)化便宜
  • 學(xué)校網(wǎng)站建設(shè)軟件推薦免費的h5制作網(wǎng)站
  • 建設(shè)網(wǎng)站建設(shè)什么掙錢互聯(lián)網(wǎng)品牌營銷公司
  • 蘇州高端網(wǎng)站建設(shè)解釋seo網(wǎng)站推廣
  • 電腦做會計從業(yè)題目用什么網(wǎng)站最新新聞事件
  • 建設(shè)銀行網(wǎng)站個人中心大量微信群推廣代發(fā)廣告
  • axure怎么做網(wǎng)站引流推廣營銷