[Interest] Aligning QProgressBar inside a QSplashScreen
techprowlcom at gmail.com
Tue Oct 2 02:30:09 CEST 2012
I am putting a QProgressBar inside a QSplashScreen by subclassing
QSplashScreen. It overrides the drawContents() method.
I thought I had set the geometry correctly, but it renders at both the top
and bottom of the screen. I don't know why. Perhaps there's another way to
align it. The numbers are correct, as the image is 380x284, so a 19 height
progress bar should be 265 pixels down.
Sorry for crappy picture, splash screen wasn't showing up with print screen
button. It's just a 1 color white splash screen at the moment, but as you
can see, progress bar at top and bottom (they're both the same colors, its
the lighting from the camera).
Another issue will be the showMessage() method of QSplashScreen. I want the
message to appear above the progress bar, right-aligned... if anyone has
any ideas how to do that.
SplashScreen::SplashScreen(QApplication *app, QWidget *parent) :
this->app = app;
// if I dont make it a child, it *only* renders at the top
progress = new QProgressBar(this);
progress->setGeometry(0, 265, 380, 19); // puts it at bottom
progress->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
connect(progress, SIGNAL(valueChanged(int)), this,
void SplashScreen::drawContents(QPainter *painter)
void SplashScreen::progressBarUpdated(int value)
class SplashScreen : public QSplashScreen
explicit SplashScreen(QApplication *app, QWidget *parent = 0);
void progressBarUpdated(int value);
void drawContents(QPainter *painter);
#endif // SPLASHSCREEN_H
int main(int argc, char *argv)
QApplication a(argc, argv);
SplashScreen *splash = new SplashScreen(&a);
// snip.. loading a ton of stuff into memory at startup
// if you're testing this you might have to sleep/timer here iono
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest