| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | 
|---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/table/qtable.cpp:1655 --> | 
|---|
| 3 | <html> | 
|---|
| 4 | <head> | 
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 
|---|
| 6 | <title>table/small-table-demo/main.cpp Example File</title> | 
|---|
| 7 | <style type="text/css"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { background: #ffffff; color: black; } | 
|---|
| 12 | --></style> | 
|---|
| 13 | </head> | 
|---|
| 14 | <body> | 
|---|
| 15 |  | 
|---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> | 
|---|
| 17 | <tr bgcolor="#E5E5E5"> | 
|---|
| 18 | <td valign=center> | 
|---|
| 19 | <a href="index.html"> | 
|---|
| 20 | <font color="#004faf">Home</font></a> | 
|---|
| 21 | | <a href="classes.html"> | 
|---|
| 22 | <font color="#004faf">All Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main Classes</font></a> | 
|---|
| 25 | | <a href="annotated.html"> | 
|---|
| 26 | <font color="#004faf">Annotated</font></a> | 
|---|
| 27 | | <a href="groups.html"> | 
|---|
| 28 | <font color="#004faf">Grouped Classes</font></a> | 
|---|
| 29 | | <a href="functions.html"> | 
|---|
| 30 | <font color="#004faf">Functions</font></a> | 
|---|
| 31 | </td> | 
|---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>table/small-table-demo/main.cpp Example File</h1> | 
|---|
| 33 |  | 
|---|
| 34 |  | 
|---|
| 35 | <pre>/**************************************************************************** | 
|---|
| 36 | ** $Id: table-small-table-demo-main-cpp.html 2051 2007-02-21 10:04:20Z chehrlic $ | 
|---|
| 37 | ** | 
|---|
| 38 | ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved. | 
|---|
| 39 | ** | 
|---|
| 40 | ** This file is part of an example program for Qt.  This example | 
|---|
| 41 | ** program may be used, distributed and modified without limitation. | 
|---|
| 42 | ** | 
|---|
| 43 | *****************************************************************************/ | 
|---|
| 44 |  | 
|---|
| 45 | #include <<a href="qapplication-h.html">qapplication.h</a>> | 
|---|
| 46 | #include <<a href="qtable-h.html">qtable.h</a>> | 
|---|
| 47 | #include <<a href="qimage-h.html">qimage.h</a>> | 
|---|
| 48 | #include <<a href="qpixmap-h.html">qpixmap.h</a>> | 
|---|
| 49 | #include <<a href="qstringlist-h.html">qstringlist.h</a>> | 
|---|
| 50 |  | 
|---|
| 51 | // Qt logo: static const char *qtlogo_xpm[] | 
|---|
| 52 | #include "qtlogo.xpm" | 
|---|
| 53 |  | 
|---|
| 54 | // Table size | 
|---|
| 55 |  | 
|---|
| 56 | const int numRows = 30; | 
|---|
| 57 | const int numCols = 10; | 
|---|
| 58 |  | 
|---|
| 59 | // The program starts here. | 
|---|
| 60 |  | 
|---|
| 61 | int main( int argc, char **argv ) | 
|---|
| 62 | { | 
|---|
| 63 | <a href="qapplication.html">QApplication</a> app( argc, argv ); | 
|---|
| 64 |  | 
|---|
| 65 | <a href="qtable.html">QTable</a> table( numRows, numCols ); | 
|---|
| 66 |  | 
|---|
| 67 | <a name="x2800"></a>    <a href="qheader.html">QHeader</a> *header = table.<a href="qtable.html#horizontalHeader">horizontalHeader</a>(); | 
|---|
| 68 | <a name="x2798"></a>    header-><a href="qheader.html#setLabel">setLabel</a>( 0, QObject::tr( "Tiny" ), 40 ); | 
|---|
| 69 | header-><a href="qheader.html#setLabel">setLabel</a>( 1, QObject::tr( "Checkboxes" ) ); | 
|---|
| 70 | header-><a href="qheader.html#setLabel">setLabel</a>( 5, QObject::tr( "Combos" ) ); | 
|---|
| 71 | <a name="x2802"></a>    table.<a href="qtable.html#setColumnMovingEnabled">setColumnMovingEnabled</a>(TRUE); | 
|---|
| 72 |  | 
|---|
| 73 | <a href="qimage.html">QImage</a> img( qtlogo_xpm ); | 
|---|
| 74 | <a name="x2801"></a><a name="x2799"></a>    <a href="qpixmap.html">QPixmap</a> pix = img.<a href="qimage.html#scaleHeight">scaleHeight</a>( table.<a href="qtable.html#rowHeight">rowHeight</a>(3) ); | 
|---|
| 75 | <a name="x2804"></a>    table.<a href="qtable.html#setPixmap">setPixmap</a>( 3, 2, pix ); | 
|---|
| 76 | <a name="x2805"></a>    table.<a href="qtable.html#setText">setText</a>( 3, 2, "A Pixmap" ); | 
|---|
| 77 |  | 
|---|
| 78 | <a href="qstringlist.html">QStringList</a> comboEntries; | 
|---|
| 79 | comboEntries << "one" << "two" << "three" << "four"; | 
|---|
| 80 |  | 
|---|
| 81 | for ( int i = 0; i < numRows; ++i ){ | 
|---|
| 82 | <a href="qcombotableitem.html">QComboTableItem</a> * item = new <a href="qcombotableitem.html">QComboTableItem</a>( &table, comboEntries, FALSE ); | 
|---|
| 83 | <a name="x2797"></a>        item-><a href="qcombotableitem.html#setCurrentItem">setCurrentItem</a>( i % 4 ); | 
|---|
| 84 | <a name="x2803"></a>        table.<a href="qtable.html#setItem">setItem</a>( i, 5, item ); | 
|---|
| 85 | } | 
|---|
| 86 | for ( int j = 0; j < numRows; ++j ) | 
|---|
| 87 | table.<a href="qtable.html#setItem">setItem</a>( j, 1, new <a href="qchecktableitem.html">QCheckTableItem</a>( &table, "Check me" ) ); | 
|---|
| 88 |  | 
|---|
| 89 | app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &table ); | 
|---|
| 90 | table.<a href="qwidget.html#show">show</a>(); | 
|---|
| 91 | return app.<a href="qapplication.html#exec">exec</a>(); | 
|---|
| 92 | } | 
|---|
| 93 | </pre><!-- eof --> | 
|---|
| 94 | <p><address><hr><div align=center> | 
|---|
| 95 | <table width=100% cellspacing=0 border=0><tr> | 
|---|
| 96 | <td>Copyright © 2007 | 
|---|
| 97 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> | 
|---|
| 98 | <td align=right><div align=right>Qt 3.3.8</div> | 
|---|
| 99 | </table></div></address></body> | 
|---|
| 100 | </html> | 
|---|