How to splash screen a gif video
-
QMovie *movie = new QMovie("C:/Users/data/Documents/untitled14/200w.gif");
QLabel *processLabel = new QLabel(NULL);
processLabel->setMovie(movie);
movie->start();
processLabel->setWindowFlags(Qt::FramelessWindowHint);
processLabel->setGeometry(
QStyle::alignedRect(
Qt::RightToLeft,
Qt::AlignCenter,
processLabel->size(),
qApp->desktop()->availableGeometry()
));
processLabel->show();This Is my current code
-
#include "mainwindow.h"
#include <QApplication>
#include<QSplashScreen>
#include<QTimer>
#include<QMovie>
#include<QLabel>
#include<QLayout>
#include<QBoxLayout>
#include <QStyle>
#include <QDesktopWidget>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
QMovie *movie = new QMovie("C:/Users/data/Documents/untitled14/200w.gif");
QLabel *processLabel = new QLabel(NULL);
processLabel->setMovie(movie);
movie->start();
processLabel->setWindowFlags(Qt::FramelessWindowHint);
processLabel->setAlignment(Qt::AlignCenter);
processLabel->setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
processLabel->size(),
qApp->desktop()->availableGeometry()
)
);
processLabel->show();QTimer::singleShot(2500,processLabel,SLOT(close())); QTimer::singleShot(2500,&w,SLOT(show())); //w.show(); return a.exec();
}
My full main.cpp code
-
Hi
Your code works just fine ?int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; QMovie *movie = new QMovie(":/kTTdW2l.gif"); QLabel *processLabel = new QLabel(nullptr); processLabel->resize(200,200); // to make sure its large enough processLabel->setMovie(movie); processLabel->setWindowFlags(Qt::FramelessWindowHint); processLabel->setAlignment(Qt::AlignCenter); processLabel->setGeometry( QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,processLabel->size(),qApp->desktop()->availableGeometry()) ); movie->start(); processLabel->show(); QTimer::singleShot(2500,processLabel,SLOT(close())); QTimer::singleShot(2500,&w,SLOT(show())); return a.exec(); }