PDA

View Full Version : QSplashScreen loading icon



talk2amulya
13th February 2009, 09:25
hi,

I am using a QSplashScreen with a loading gif icon on it..and although the splashscreen shows, the loading icon doesnt show animation..i m already using QMovie with the gif icon and have started the movie..if i place a messagebox in the processing(till the application shows), the loading icon animates..although if i stop it, there is no animation..i have also used processEvents but it still doesnt work..Could anyone please direct me to a possible solution?

Thanks
Amulya

jacek
14th February 2009, 00:45
Where did you put processEvents()? QMovie needs a running event loop to operate.

talk2amulya
14th February 2009, 05:10
well, after i show the splash screen with the loading icon, there is a LOT of processing going on like loading plugins, certain interfaces, lots of initialization and other things..due to which the loading icon doesnt animate at all..after i put a number of processEvents() around, it did start to move intermittently..but still its not smooth..i cant show the splash screen in another thread also cuz of gui operations..i dont see any other options to show the animations on it..could u suggest anth..i cant use a QEventLoop either..doesnt make any sense..until this QMovie doesnt get its own seperate running event loop, i dont think it'll work..any directions would be helpful

Thanks

talk2amulya
15th February 2009, 22:18
all u good guys.. please direct me into solving this issue

aamer4yu
16th February 2009, 05:18
Not sure if this will work,,, but you can try putting the loading logic in QSplashScreen class.

talk2amulya
16th February 2009, 06:53
no man, thats not going to work at all...

sepehr
16th February 2009, 10:32
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(QWidget *parent=0);
~workingIcon();

private:
QMovie *movie;
QPixmap WinMask;
};
#endif


workingAnimation.cpp file


#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;
}

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 ;)

talk2amulya
16th February 2009, 10:46
i've done the same thing already man, the problem is that loading icon doesnt get events processed for it to be shown as animated..the other intensive loading work is takin all cpu cycles due to which the loading icon doesnt get animated properly..the problem is smwhere in event handling of QMovie...