×
Namespaces

Variants
Actions
Revision as of 05:35, 30 April 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Splash screen in Qt for Symbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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.

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 ExampleCompatibility
Platform(s):
Symbian
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.
This page was last modified on 30 April 2013, at 05:35.
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×