1 | /****************************************************************************
|
---|
2 | ** $Id: main.cpp 160 2006-12-11 20:15:57Z dmik $
|
---|
3 | **
|
---|
4 | ** Copyright (C) 1992-2000 Trolltech AS. 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 <qtable.h>
|
---|
13 | #include <qimage.h>
|
---|
14 | #include <qpixmap.h>
|
---|
15 | #include <qstringlist.h>
|
---|
16 |
|
---|
17 | // Qt logo: static const char *qtlogo_xpm[]
|
---|
18 | #include "qtlogo.xpm"
|
---|
19 |
|
---|
20 | // Table size
|
---|
21 |
|
---|
22 | const int numRows = 30;
|
---|
23 | const int numCols = 10;
|
---|
24 |
|
---|
25 | // The program starts here.
|
---|
26 |
|
---|
27 | int main( int argc, char **argv )
|
---|
28 | {
|
---|
29 | QApplication app( argc, argv );
|
---|
30 |
|
---|
31 | QTable table( numRows, numCols );
|
---|
32 |
|
---|
33 | QHeader *header = table.horizontalHeader();
|
---|
34 | header->setLabel( 0, QObject::tr( "Tiny" ), 40 );
|
---|
35 | header->setLabel( 1, QObject::tr( "Checkboxes" ) );
|
---|
36 | header->setLabel( 5, QObject::tr( "Combos" ) );
|
---|
37 | header->setMovingEnabled(TRUE);
|
---|
38 |
|
---|
39 | QImage img( qtlogo_xpm );
|
---|
40 | QPixmap pix = img.scaleHeight( table.rowHeight(3) );
|
---|
41 | table.setPixmap( 3, 2, pix );
|
---|
42 | table.setText( 3, 2, "A Pixmap" );
|
---|
43 |
|
---|
44 | QStringList comboEntries;
|
---|
45 | comboEntries << "one" << "two" << "three" << "four";
|
---|
46 |
|
---|
47 | for ( int i = 0; i < numRows; ++i ){
|
---|
48 | QComboTableItem * item = new QComboTableItem( &table, comboEntries, FALSE );
|
---|
49 | item->setCurrentItem( i % 4 );
|
---|
50 | table.setItem( i, 5, item );
|
---|
51 | }
|
---|
52 | for ( int j = 0; j < numRows; ++j )
|
---|
53 | table.setItem( j, 1, new QCheckTableItem( &table, "Check me" ) );
|
---|
54 |
|
---|
55 | app.setMainWidget( &table );
|
---|
56 | table.show();
|
---|
57 | return app.exec();
|
---|
58 | }
|
---|