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

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

iis 添加網(wǎng)站 win7種子搜索神器

iis 添加網(wǎng)站 win7,種子搜索神器,哈爾濱市松北區(qū)政府網(wǎng),商丘網(wǎng)絡(luò)營銷服務(wù)目錄 QSplashScreen 類介紹 使用方式 項目中使用 THPrinterSplashScreen頭文件 THPrinterSplashScreen實現(xiàn)代碼 使用代碼 使用效果 QSplashScreen 類介紹 QSplashScreen 是 Qt 中的一個類,用于顯示啟動畫面。它通常在應(yīng)用程序啟動時顯示,以向用戶顯…

目錄

QSplashScreen 類介紹

?使用方式

項目中使用

THPrinterSplashScreen頭文件

?THPrinterSplashScreen實現(xiàn)代碼

使用代碼?

使用效果

?


QSplashScreen 類介紹

?????????QSplashScreen?是?Qt?中的一個類,用于顯示啟動畫面。它通常在應(yīng)用程序啟動時顯示,以向用戶顯示應(yīng)用程序正在啟動的狀態(tài)。啟動畫面可以是一個圖片,也可以是一個包含了文本、圖片等內(nèi)容的窗口。

QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())

QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())


virtual?~QSplashScreen()


void?finish(QWidget *mainWin)

QString?message() const


const QPixmap?pixmap() const


void?repaint()


void? setPixmap(const QPixmap &pixmap)

//slots
void?clearMessage()
void?showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black)

//protected 可以繼承自繪
virtual void?drawContents(QPainter *painter)
?

?使用方式

????????以下是Qt官方文檔給出的兩種使用場景。

? 作為主窗口啟動前的啟動動畫

  int main(int argc, char *argv[]){QApplication app(argc, argv);QPixmap pixmap(":/splash.png");QSplashScreen splash(pixmap);splash.show();app.processEvents();...QMainWindow window;window.show();splash.finish(&window);return app.exec();}

主窗口啟動前軟件啟動提示信息

  QPixmap pixmap(":/splash.png");QSplashScreen *splash = new QSplashScreen(pixmap);splash->show();... // Loading some itemssplash->showMessage("Loaded modules");qApp->processEvents();... // Establishing connectionssplash->showMessage("Established connections");qApp->processEvents();

項目中使用

? ? ? ? 實際項目中如果軟件啟動比較耗時,一般需要根據(jù)軟件的樣式風格和互動需求自定義啟動動畫效果,此時virtual void?drawContents(QPainter *painter) 和?repaint()就顯得尤為重要。

????????以下是根據(jù)自身項目,加載啟動動畫時顯示軟件版本信息和啟動進度等信息,主要繼承drawContents進行重繪。

THPrinterSplashScreen頭文件

#ifndef THPrinterSplashScreenT_H
#define THPrinterSplashScreenT_H#include <QSplashScreen>
#include "Common.h"#define g_pSplashScreen Singleton<THPrinterSplashScreen>::getInstance()class THPrinterSplashScreen : public QSplashScreen
{Q_OBJECTfriend Singleton<THPrinterSplashScreen>;
public://關(guān)閉自身前可以再次操作void finish(QWidget *w);//設(shè)置啟動進度0-100void setProgressValue(int value);//設(shè)置啟動提示信息 如庫加載信息、數(shù)據(jù)庫啟動...void setTipStr(const QString&tipStr);protected://重寫此函數(shù) 自定義繪制啟動動畫void drawContents(QPainter *painter) override;
private:THPrinterSplashScreen();~THPrinterSplashScreen() = default;QPixmap m_pixIcon;QPixmap m_picBackground;int     m_nProgressValue = 0;QString m_strTip;
};#endif // THPrinterSplashScreenT_H

?THPrinterSplashScreen實現(xiàn)代碼


#pragma execution_character_set("utf-8")THPrinterSplashScreen::THPrinterSplashScreen()	
{m_picBackground.load(":/images/icon/background.png");m_pixIcon.load(":/images/icon/logo.png");setPixmap(m_picBackground);setWindowFlag(Qt::WindowStaysOnTopHint);
}void THPrinterSplashScreen::finish(QWidget *w)
{setProgressValue(100);setTipStr("程序加載完成!");QSplashScreen::finish(w);
}void THPrinterSplashScreen::setProgressValue(int value)
{if (isVisible() && value >= 0 && m_nProgressValue < value) {value = qBound(0, value,100);m_nProgressValue = value;repaint();}
}void THPrinterSplashScreen::setTipStr(const QString&tipStr)
{if (isVisible() && !tipStr.isEmpty() && m_strTip != tipStr) {m_strTip = tipStr;repaint();}
}void THPrinterSplashScreen::drawContents(QPainter *painter)
{QSplashScreen::drawContents(painter);int bg_w = m_picBackground.width();int bg_h = m_picBackground.height();int icon_w = m_pixIcon.width();int icon_h = m_pixIcon.height();//默認垂直方向dpi為96 防止不同設(shè)備分辨率不同字體差異過大float fFactor = logicalDpiY() / 96.0f; int smallFontSize = qRound(10 * fFactor);int midFontSize = qRound(15 * fFactor);int bigFontSize = qRound(20 * fFactor);int fontGapSize = 6;int magrinGapSize = 10;int offset = -20;int icon_x = (bg_w - icon_w) / 2;int icon_y = (bg_h - icon_h) / 2  + offset;int text_name_y = (bg_h + icon_h) / 2 + magrinGapSize + offset;int text_TipStr_y = text_name_y + bigFontSize + fontGapSize;int text_version_y = bg_h - fontGapSize - midFontSize;QRect rect_Icon(icon_x, icon_y, icon_w, icon_h);//相對于parent 左上角坐標 長寬QRect rect_Name_Text(0, text_name_y, bg_w, bigFontSize + fontGapSize);QRect rect_TipStr_Text(0, text_TipStr_y, bg_w, smallFontSize + fontGapSize);QRect rect_Version_Text(0, text_version_y, bg_w, midFontSize + fontGapSize);// 繪制啟動動畫logopainter->drawPixmap(rect_Icon, m_pixIcon);//繪制軟件名稱auto font = painter->font();font.setBold(true);font.setPointSize(bigFontSize);painter->setFont(font);auto pen = painter->pen();pen.setColor(Qt::white);painter->setPen(pen);painter->drawText(rect_Name_Text, Qt::AlignCenter, tr("設(shè)備指紋燒錄工具"));//繪制啟動中提示信息font = painter->font();font.setBold(false);font.setPointSize(smallFontSize);painter->setFont(font);if (!m_strTip.isEmpty()){painter->drawText(rect_TipStr_Text, Qt::AlignCenter, m_strTip);}//繪制軟件版本信息font = painter->font();font.setPointSize(midFontSize);painter->setFont(font);auto &strVersion = PmsUpDater::getVersion();if (!strVersion.isEmpty()) {painter->drawText(rect_Version_Text, Qt::AlignCenter, strVersion);}//在rect_Version_Text最右側(cè)繪制軟件啟動進度if (m_nProgressValue >= 0) {rect_Version_Text.adjust(0, 0, -midFontSize, 0);painter->drawText(rect_Version_Text,Qt::AlignVCenter | Qt::AlignRight,QString("%1%").arg(m_nProgressValue));}
}

使用代碼?

main函數(shù)中嵌入到軟件主界面啟動前后。

	int main(int argc, char *argv[]){//...g_pSplashScreen->setProgressValue(0);g_pSplashScreen->show();PmsUpDater w;w.show();g_pSplashScreen->finish(&w);//...return a.exec();}

????????在程序啟動比較耗時的地方添加進度信息和提示信息,便于判斷程序啟動的狀態(tài),若程序啟動失敗也可作為定位失敗位置的信息。

int THPrinter::Initial(){//...//初始化SDKInitialSdk();g_pSplashScreen->setTipStr("SDK初始化成功!");g_pSplashScreen->setProgressValue(53);//...//數(shù)據(jù)庫連接開始g_pSplashScreen->setTipStr("數(shù)據(jù)庫連接中...");g_pSplashScreen->setProgressValue(56);//...//連接完成g_pSplashScreen->setTipStr("數(shù)據(jù)庫連完成");g_pSplashScreen->setProgressValue(57);//...}

使用效果

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

相關(guān)文章:

  • 怎么做網(wǎng)站點擊率監(jiān)控工具國內(nèi)seo做最好的公司
  • 大安網(wǎng)站建設(shè)網(wǎng)站制作公司有哪些
  • 如何尋找一批做網(wǎng)站的公司查看今日頭條
  • 開發(fā)網(wǎng)站比較好的公司公司網(wǎng)絡(luò)搭建
  • 滄州網(wǎng)站建沒搜狗營銷
  • 做網(wǎng)站 科目今天發(fā)生的新聞
  • 本地房產(chǎn)交易信息網(wǎng)人員優(yōu)化方案
  • 濰坊??茖W校深圳seo排名
  • 諸城網(wǎng)站建設(shè)電子商務(wù)網(wǎng)店運營推廣
  • 開個網(wǎng)站需要什么條件福建省人民政府
  • 東營定制網(wǎng)站建設(shè)服務(wù)成人編程培訓機構(gòu)排名前十
  • 免費主機空間網(wǎng)絡(luò)營銷優(yōu)化培訓
  • 在線注冊個體工商戶企業(yè)seo關(guān)鍵詞優(yōu)化
  • 免費行情網(wǎng)站北京sem
  • 西寧微信網(wǎng)站建設(shè)需要多少錢網(wǎng)店運營與推廣
  • dede建設(shè)網(wǎng)站教程sem推廣
  • 商務(wù)部網(wǎng)站建設(shè)情況匯報公司seo排名優(yōu)化
  • 如何制作一個自己的網(wǎng)站中國十大經(jīng)典廣告
  • 做網(wǎng)絡(luò)銷售都做什么網(wǎng)站饑餓營銷的十大案例
  • 佛山專業(yè)網(wǎng)站營銷seo是什么意思網(wǎng)絡(luò)用語
  • 平面設(shè)計類網(wǎng)站app開發(fā)公司排行榜
  • 湖南建設(shè)廳網(wǎng)站不良記錄數(shù)據(jù)分析師資格證書怎么考
  • 門戶網(wǎng)站意思種子搜索引擎在線
  • 做網(wǎng)站業(yè)務(wù)員提成幾個點網(wǎng)絡(luò)營銷的渠道有哪些
  • 建設(shè)網(wǎng)站的目的服裝類鎮(zhèn)江網(wǎng)站定制
  • 蕪湖做網(wǎng)站的鄧健照片企業(yè)培訓
  • 做網(wǎng)站的費用 可以抵扣嗎網(wǎng)絡(luò)整合營銷4i原則
  • 下載app軟件安裝搜索引擎優(yōu)化公司排行
  • 網(wǎng)站開發(fā)連接形式合肥網(wǎng)站優(yōu)化推廣方案
  • 刪除wordpress站高端營銷型網(wǎng)站