分析一下github中项目的软件启动画面的实现

引用这个老外的一些资源了呀。。。。。。。。。。。。。。。。。

分析一下github中项目的软件启动画面的实现_第1张图片分析一下github中项目的软件启动画面的实现_第2张图片分析一下github中项目的软件启动画面的实现_第3张图片

分析一下github中项目的软件启动画面的实现_第4张图片分析一下github中项目的软件启动画面的实现_第5张图片分析一下github中项目的软件启动画面的实现_第6张图片

分析一下github中项目的软件启动画面的实现_第7张图片分析一下github中项目的软件启动画面的实现_第8张图片


看到了,很简单,就是一帧帧的png图片。下面是他的代码,就是开启一个定时器,每隔一段时间刷新出一帧新的图片,

当所有图片显示完成后,启动界面结束。感觉还不如整个gif图片呢。其实这倒无所谓,反正动画(电影)也就是一帧帧的图像组成的。


#ifndef LOADSPLASH_H
#define LOADSPLASH_H

#include 
#include 
#include 

//! The LoadSplash class.
/*!
    Animated splash screen.
 */
class LoadSplash : public QObject
{
    Q_OBJECT
public:

    //! Constructor LoadSplash class.
    /*!
        Load images
        \param screen Used splash screen
        \param interval Time interval of pictures
        \param parent Parent widget
     */
    explicit LoadSplash(QSplashScreen * screen, int interval, QObject *parent = 0);

    //! Start animation.
    void start();

private:
    //! Timer Event.
    /*!
        Show images
        \param event Timer event
     */
    void timerEvent(QTimerEvent *event);

private:
    QSplashScreen * _screen;   //!< Used splash screen
    QList<QPixmap>  _pixmaps;  //!< List of Pictures
    int             _interval; //!< Time interval of pictures
};

#endif // LOADSPLASH_H


#include "loadsplash.h"

LoadSplash::LoadSplash(QSplashScreen * screen, int interval, QObject *parent) :
    QObject(parent)
{
    _screen   = screen;
    _interval = interval;

    _pixmaps.append(QPixmap (":/logos/logoShow1.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow2.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow3.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow4.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow5.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow6.png"));
    _pixmaps.append(QPixmap (":/logos/logoShow7.png"));
}

void LoadSplash::start()
{
    startTimer(_interval);
}

void LoadSplash::timerEvent(QTimerEvent *event)
{
    if(!_pixmaps.isEmpty())
    {
        _screen->setPixmap(_pixmaps.takeFirst());
    }
    else
    {
        killTimer(event->timerId());
    }
}
 by zhangshaoyan at June 17,2015.

你可能感兴趣的:(软件技术)