Home · All Classes · Grouped Classes · Annotated · Functions

Writing Applications that Start Quickly

Introduction

Application startup time is critical on consumer devices. This document describes techniques for making Qtopia applications start as quickly as possible.

Delaying code execution.

Making an application start quickly is closely related to how much code is executed during the startup process. Some of the common operations that can affect startup time are:

The simplest way to improve startup time is to defer some of these operations until after the user interface is visible. If possible, perform the operation on demand, for example, do not create a dialog until it is actually needed:

    MainWidget::MainWidget( QWidget *parent, Qt::WFlags f )
        : QMainWindow( parent, f ), settingsDialog(0)
    {
    }

    void MainWidget::showSettings()
    {
        // If settingsDialog has not yet been created, create it now.
        if ( !settingsDialog )
            settingsDialog = new SettingsDialog( this );
        settingsDialog->exec();
    }

If the operation is required immediately after the application is visible, a single shot timer may be used to start the processing after the main widget is visible:

    MainWidget::MainWidget( QWidget *parent, Qt::WFlags f )
        : QMainWindow( parent, f ), settingsDialog(0)
    {
        // After the event queue has been processed and the mainwindow is
        // visible, load the data.
        QTimer::singleShot(0, this, SLOT(loadData()));
    }

    void MainWidget::loadData()
    {
        // Open data file and populate data view.
    }


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3