Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

Mainly Easy

(main.cpp.)

    #include <qapplication.h>
    #include "chartform.h"

    int main( int argc, char *argv[] )
    {
        QApplication app( argc, argv );

        QString filename;
        if ( app.argc() > 1 ) {
            filename = app.argv()[1];
            if ( !filename.endsWith( ".cht" ) )
                filename = QString::null;
        }

        ChartForm *cf = new ChartForm( filename );
        app.setMainWidget( cf );
        cf->show();

        return app.exec();
    }

We have kept the main() function simple and small. We create a QApplication object and pass it the command line arguments. We are allowing users to invoke the program with chart mychart.cht, so if they've added a filename we pass that through to the chart form constructor. Most of the action takes place within the chart form which we'll review next.

« Data Elements | Contents | Presenting the GUI »


Copyright © 2003 TrolltechTrademarks
Qt version 3.2.0b2