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

Mainly Easy

(main.cpp.)

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

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

        TQString filename;
        if ( app.argc() > 1 ) {
            filename = app.argv()[1];
            if ( !filename.endsWith( ".cht" ) )
                filename = TQString::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 TQApplication 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 © 2007 TrolltechTrademarks
TQt 3.3.8