View Full Version : QSplashScreen with QProgressBar
Ratheendrans
1st December 2010, 10:21
Hi All,
I want to put a Splash Screen with a progress bar showing the update,I have seen some of the example on Internet they are either incomplete or do not work.
can any give me a sample code example of implementation ,or links to working example.
Thanks,
Ratheendran
BalaQT
1st December 2010, 12:15
QProgressBar syntax
QProgressBar *pbar = new QProgressBar();
pBar->setMinimum(0);
pBar->setMaximum(100);
hope it helps
Bala
Ratheendrans
1st December 2010, 12:28
Hi All,
I tried including progress bar in QSplashScreen with some success.
However I am not aware on updating the progress bar from the main progamme.
I am sharing the code below,in this code drawContents() is called only once.
class customSplashScreen: public QSplashScreen
{
QProgressBar *m_pProgressBar;
public:
customSplashScreen(const QPixmap& pixmap);
~customSplashScreen();
virtual void drawContents(QPainter *painter);
};
customSplashScreen::customSplashScreen(const QPixmap& pixmap):QSplashScreen(pixmap)
{
m_pProgressBar = new QProgressBar (this);
m_pProgressBar->setMinimum(0);
m_pProgressBar->setMaximum(100);
m_pProgressBar->show();
};
customSplashScreen::~customSplashScreen()
{
};
void customSplashScreen::drawContents(QPainter *painter)
{
m_pProgressBar->setValue(24);
m_pProgressBar->update ();
};
2.now in my main.cpp
main()
{
QPixmap pixmap("/home/sky/myimage.png");
customSplashScreen *splash = new customSplashScreen(pixmap);
splash->show();
// do some task and update the progress bar finally calling my main application
}
Kindly give your valuable suggestions.
Thanks and Regards,
Ratheendran
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.