Solved Splash screen not showing messages
-
I can successfully show a splash screen while my application is starting, and it goes away when I want it to. But the messages I want to show do not appear. I have tried both repaint and process events, as in the code below. What am I missing?
Code:
@@
Application a(argc, argv);
QPixmap pixmap(":/cap/1.6 aspect ratio for splash screen.jpg");
QSplashScreen splash(pixmap);
splash.show();
sleep(1);
splash.showMessage(QApplication::translate("Setting Product Attributes...", 0), Qt::AlignLeft, Qt::black);
splash.repaint(); // ensure progress is shown
qApp->processEvents();
sleep(2);
splash.showMessage(QApplication::translate("Confirming Registration...", 0), Qt::AlignLeft, Qt::black);
splash.repaint(); // ensure progress is shown
qApp->processEvents();
sleep(2);
splash.showMessage(QApplication::translate("Loading Client Application...", 0), Qt::AlignLeft, Qt::black);
splash.repaint(); // ensure progress is shown
qApp->processEvents();
@@Of course I will do something ore than just "sleep", but I wanted to get the messages workign before moving further.
Thank you,
Andy -
I didn't get any posts from others, but in the meantime I did get this to work so perhaps posting the solution will be helpful for the list. It turns out - not sure why - that the QApplication::translate calls I was making are ignored by QSplashScreen. I found another post on the forum at https://forum.qt.io/topic/1911/solved-shows-splashscreen-but-does-not-show-its-message, that uses something I had not been aware of, QSplashScreen::tr, instead... and this works!