source: trunk/examples/sql/overview/table2/main.cpp

Last change on this file was 202, checked in by rudi, 14 years ago

Added SQL examples

File size: 1.1 KB
Line 
1/****************************************************************************
2** $Id: main.cpp 2051 2007-02-21 10:04:20Z chehrlic $
3**
4** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9*****************************************************************************/
10
11#include <qapplication.h>
12#include <qsqldatabase.h>
13#include <qsqlcursor.h>
14#include <qdatatable.h>
15#include "../connection.h"
16
17int main( int argc, char *argv[] )
18{
19 QApplication app( argc, argv );
20
21 if ( createConnections() ) {
22 QSqlCursor staffCursor( "staff" );
23
24 QDataTable *staffTable = new QDataTable( &staffCursor );
25
26 app.setMainWidget( staffTable );
27
28 staffTable->addColumn( "forename", "Forename" );
29 staffTable->addColumn( "surname", "Surname" );
30 staffTable->addColumn( "salary", "Annual Salary" );
31
32 QStringList order = QStringList() << "surname" << "forename";
33 staffTable->setSort( order );
34
35 staffTable->refresh();
36 staffTable->show();
37
38 return app.exec();
39 }
40
41 return 1;
42}
Note: See TracBrowser for help on using the repository browser.