Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
Application startup time is critical on consumer devices. This document describes techniques for making Qt Extended applications start as quickly as possible.
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 © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |