Putting It All Together

Now we have the code for our dialog, all we need is some test harness to try it. The following code is about the simplest piece you can have:

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

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

  PizzaEntry* pizzaEntry = new PizzaEntry;
  pizzaEntry->show();
  app.setMainWidget( pizzaEntry );
  int ret = app.exec();
  delete pizzaEntry;
  return ret;
}

Save this as PizzaEntryTest.cpp. Now you can start building your program. On a Unix system with the g++ compiler, these could be your command lines:

moc -o moc_PizzaEntry.cpp PizzaEntry.h
g++ -I$QTDIR/include PizzaEntry.cpp PizzaEntryTest.cpp \
	moc_PizzaEntry.cpp -L$QTDIR/lib -lqt

and on a Windows system with the Microsoft Visual C++ compiler:

If you use a different compiler, you might have to change the compiler command and some of the options. If you do not know what the line starting with moc is for, please see the Qt Tutorial or Programming with Qt.

Finally, you can run your program. Figure 2-14 shows the result.

Figure 2-14. Our first program in action