Archived:Splash screen in Qt for Symbian
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated. See Implementing a Splash Screen with Qt Quick for information on doing this with QML.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated. See Implementing a Splash Screen with Qt Quick for information on doing this with QML.
This article describes how to use QSplashScreen to display a full-screen loading/waiting note at application startup, and what needs to be taken into consideration when using splash screens on Symbian touch devices.
Article Metadata
Code Example
Source file: Media:Splashtest qt symbian.zip
Article
Created: treinio
(15 Dec 2010)
Last edited: hamishwillee
(30 Apr 2013)
Detailed description
QSplashScreen provides an easy way of showing a splash screen during application startup, with a background image and text messages to keep the user updated about the progress. However, when running on a Symbian device, there are a couple of issues that need to be addressed:
Hiding softkeys
- When displaying a full-screen image, the softkeys are visible on top of the splash screen. This issue is discussed in bug report QTBUG-13156. As a workaround, raise() can be called on the splash screen instance to cover the softkey area.
QPixmap pixmap(":/images/splash.png");
QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
splash.showFullScreen();
splash.raise();
Orientation
- QSplashScreen does not handle screen orientation change properly. Therefore, it is better to lock the orientation while the splash screen is being displayed, and release it when the application main view starts (if the application supports both orientation modes). This requires the use of S60/AVKON APIs, similar to CS001517 - Lock application orientation in Qt.
#ifdef Q_WS_S60
#include <coemain.h> // add 'symbian: LIBS += -lavkon -lcone' to .pro file
#include <aknappui.h>
#endif
// Lock S60 app orientation to portrait - used when showing the splash screen
void MainWindow::lockPortraitOrientation()
{
#ifdef Q_WS_S60
CAknAppUi* s60AppUi = dynamic_cast<CAknAppUi*> (CCoeEnv::Static()->AppUi());
// save the old orientation
m_orientation = (int)s60AppUi->Orientation();
TRAP_IGNORE(
if (s60AppUi) {
// Lock portrait orientation when showing the splash screen
s60AppUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
});
#endif
}
// Releases the orientation lock (restores previous orientation)
void MainWindow::releaseOrientation()
{
// do nothing if orientation is not locked
if( m_orientation == -1 )
return;
#ifdef Q_WS_S60
CAknAppUi* s60AppUi = dynamic_cast<CAknAppUi*> (CCoeEnv::Static()->AppUi());
TRAP_IGNORE(
if (s60AppUi) {
s60AppUi->SetOrientationL((CAknAppUiBase::TAppUiOrientation)m_orientation);
});
#endif
}
User input
- By default, the user can dismiss/hide the splash screen by clicking on it. If the splash screen should be always displayed for a fixed time period or while resource loading is in progress, it's necessary to create a class derived from QSplashScreen and reimplement its mousePressEvent() function to ignore the events.
class SplashScreen : public QSplashScreen
{
Q_OBJECT
public:
explicit SplashScreen(bool blocking = false,
const QPixmap & pixmap = QPixmap(),
Qt::WindowFlags f = 0)
: QSplashScreen(pixmap, f),
m_blocking(blocking) { }
protected: // reimp
void mousePressEvent ( QMouseEvent *event ) {
if(!m_blocking)
QSplashScreen::mousePressEvent(event);
}
private:
bool m_blocking;
};
Example project
Download
Notes
- In this example code, resource loading and initialization is only simulated using timers, and happens after the main event loop is already started. In an actual application, these may occur outside the event loop, before QApplication::exec() is called. In this case, it is necessary to periodically call QApplication::processEvents() to receive user input.
- The example application support S60 5th Edition and Symbian^3 platforms - support for non-touch devices would require the application to handle different screen resolutions (using several different choices for the background image, or scaling) and also handling key events. Check the .pro file to see how platform support can be customized by using the DEPLOYMENT variable.


Utoto - Error at testing
I try to build example project without any changing and it gives error
Launch failed: Command answer [command error], 1 values(s) to request: 'C|211|Processes|start|""|"SplashTest.exe"|[""]|[]|true'
Error: 'Failed to create the process (verify that the executable and all required DLLs have been transferred) (item not found)' Code: -1
I tried at Nokia 5800 MXUtoto 17:37, 10 February 2012 (EET)
Hamishwillee - This article is archived
Hi Utoto
This article is archived as this isn't really the "right" way to create Qt apps on mobile any more (Qt Quick) is recommended. Which SDK did you use? Qt 1.1.2?
I'd be checking that my package had all the files needed.
Regards
Hamishhamishwillee 06:00, 20 February 2012 (EET)