home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / table / bigtable / main.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-28  |  1.7 KB  |  56 lines

  1. /****************************************************************************
  2. ** $Id:  qt/main.cpp   3.0.0   edited Jun 1 18:44 $
  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 <sys/uflags.h>
  14.  
  15. // Table size
  16.  
  17. const int numRows = 1000000;
  18. const int numCols = 1000000;
  19.  
  20. class MyTable : public QTable
  21. {
  22. public:
  23.     MyTable( int r, int c ) : QTable( r, c ) {
  24.     items.setAutoDelete( TRUE );
  25.     widgets.setAutoDelete( TRUE );
  26.     setCaption( tr( "This is a big table with 1.000.000x1.000.000 cells..." ) );
  27.     setLeftMargin( fontMetrics().width( "W999999W" ) );
  28.     }
  29.  
  30.     void resizeData( int ) {}
  31.     QTableItem *item( int r, int c ) const { return items.find( indexOf( r, c ) ); }
  32.     void setItem( int r, int c, QTableItem *i ) { items.replace( indexOf( r, c ), i ); }
  33.     void clearCell( int r, int c ) { items.remove( indexOf( r, c ) ); }
  34.     void insertWidget( int r, int c, QWidget *w ) { widgets.replace( indexOf( r, c ), w );  }
  35.     QWidget *cellWidget( int r, int c ) const { return widgets.find( indexOf( r, c ) ); }
  36.     void clearCellWidget( int r, int c ) { widgets.remove( indexOf( r, c ) ); }
  37.  
  38. private:
  39.     QIntDict<QTableItem> items;
  40.     QIntDict<QWidget> widgets;
  41.  
  42. };
  43.  
  44. // The program starts here.
  45.  
  46. int main( int argc, char **argv )
  47. {
  48.     _uflags(_UF_SBRK_ARBITRARY,_UF_SBRK_ARBITRARY); 
  49.     QApplication app( argc, argv );            
  50.  
  51.     MyTable table( numRows, numCols );
  52.     app.setMainWidget( &table );
  53.     table.show();
  54.     return app.exec();
  55. }
  56.