Advertisement
Guest User

Qt memory leak test

a guest
Apr 20th, 2011
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // main.h
  2.  
  3. #pragma once
  4.  
  5. #include <QtCore>
  6. #include <QtGui>
  7.  
  8. class WndTable : public QDialog
  9. {
  10.   Q_OBJECT
  11.  
  12.   public: WndTable( QWidget* parent = 0 ) :
  13.     QDialog( parent )
  14.   {
  15.     QVBoxLayout* layout = new QVBoxLayout( this );
  16.     QTableWidget* table = new QTableWidget( this );
  17.     layout->addWidget( table );
  18.  
  19.     setAttribute( Qt::WA_DeleteOnClose );
  20.     table->setColumnCount( 1 );
  21.     table->setRowCount( 128 * 1024 );
  22.     for( int i = 0; i < 128 * 1024; i ++ )
  23.     {
  24.       QTableWidgetItem* item = new QTableWidgetItem( tr( "%1" ).arg( i ) );
  25.       table->setItem( i, 0, item );
  26.     }
  27.   }
  28. };
  29.  
  30. class WndMain : public QPushButton
  31. {
  32.   Q_OBJECT
  33.  
  34.   public: WndMain( QWidget* parent = 0 ) :
  35.     QPushButton( parent )
  36.   {
  37.     connect( this, SIGNAL(clicked()), this, SLOT(OnClick()) );
  38.   }
  39.  
  40.   private slots: void OnClick()
  41.   {
  42.     (new WndTable( this ))->show();
  43.   }
  44. };
  45.  
  46. // main.cpp
  47.  
  48.  
  49. #include "main.h"
  50.  
  51. int main( int argc, char** argv )
  52. {
  53.   QApplication app( argc, argv );
  54.   WndMain wndMain;
  55.   wndMain.setText( "Click me" );
  56.   wndMain.show();
  57.  
  58.   return app.exec();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement