I have created a specific class for my loading:
workingAnimation.h file
#include <QLabel>
#include <QMovie>
#ifndef workingIcon_CLASS
#define workingIcon_CLASS
class workingIcon
:public QLabel{
public:
~workingIcon();
private:
};
#endif
#include <QLabel>
#include <QMovie>
#ifndef workingIcon_CLASS
#define workingIcon_CLASS
class workingIcon:public QLabel
{
public:
workingIcon(QWidget *parent=0);
~workingIcon();
private:
QMovie *movie;
QPixmap WinMask;
};
#endif
To copy to clipboard, switch view to plain text mode
workingAnimation.cpp file
#include "workingAnimation.h"
#include <QPixmap>
#include <QBitmap>
#include <QDebug>
#include <QDesktopWidget>
#include <QApplication>
workingIcon
::workingIcon(QWidget *parent
){
setWindowFlags(Qt::FramelessWindowHint);
setWindowModality(Qt::ApplicationModal);
movie
=new QMovie(":images/working.gif");
movie->jumpToFrame(movie->frameCount());
WinMask=movie->currentPixmap();
setMask(WinMask.mask());
setMovie(movie);
movie->start();
int w = desktop->width(); // returns desktop width
int h = desktop->height(); // returns desktop height
move(int((w/2)-(WinMask.width())),int((h/2)-(WinMask.height())));
}
workingIcon::~workingIcon()
{
qDebug()<<"clearing movie Object";
//delete movie;
}
#include "workingAnimation.h"
#include <QPixmap>
#include <QBitmap>
#include <QDebug>
#include <QDesktopWidget>
#include <QApplication>
workingIcon::workingIcon(QWidget *parent)
:QLabel(parent)
{
setWindowFlags(Qt::FramelessWindowHint);
setWindowModality(Qt::ApplicationModal);
movie=new QMovie(":images/working.gif");
movie->jumpToFrame(movie->frameCount());
WinMask=movie->currentPixmap();
setMask(WinMask.mask());
setMovie(movie);
movie->start();
QDesktopWidget *desktop = QApplication::desktop();
int w = desktop->width(); // returns desktop width
int h = desktop->height(); // returns desktop height
move(int((w/2)-(WinMask.width())),int((h/2)-(WinMask.height())));
}
workingIcon::~workingIcon()
{
qDebug()<<"clearing movie Object";
//delete movie;
}
To copy to clipboard, switch view to plain text mode
the gif for the loading is embedded into resources , now you just have to instantiate the class and call show method and call the close method when your preferred data has been loaded,hope it works
Bookmarks