QSplashScreen用QThead定時

不重載QSplashScreen也可以實現定時,用QThead的sleep方法,不過需要封裝成public 的方法

class I : public QThread
{
public:
	static void sleep(unsigned long secs) {
		QThread::sleep(secs);
	}
};

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	QTextCodec *codec = QTextCodec::codecForLocale();
	QTextCodec::setCodecForCStrings(codec);
	QTextCodec::setCodecForTr(codec);

	//Initial Welcome screen
	QSplashScreen *splash = new QSplashScreen(QPixmap(":/image/title.png"));
	splash->show();
	Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
	splash->showMessage("loading modules...",topRight,Qt::black);

	mainFrame *mFrame  = new mainFrame;
	LaunchWin launchWin(mFrame);
	I::sleep(3);
	splash->finish(&launchWin);

	launchWin.show();
	
	return a.exec();
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章