Hey,

I'm currently making my own tablewidget because i want to have more than a thousand rows and columns and QTableWidget takes too much memory.
So i started working on it, and this is what i currently have:

Qt Code:
  1. //mytable.cpp
  2. #include <QtGui/QApplication>
  3. #include <QtGui/QMainWindow>
  4. #include <QtGui/QColor>
  5. #include <QtGui/QBrush>
  6. #include "mytable.h"
  7.  
  8. mytable::mytable( QWidget* parent) : QWidget( parent ) {
  9. }
  10.  
  11. void mytable::paintEvent( QPaintEvent* event ) {
  12. QPainter* painter=new QPainter(this);
  13. QSize _size = size();
  14. QBrush brush( QColor(0,150,0)/*, Qt::LinearGradientPattern*/);
  15. painter->fillRect(0,0, _size.width(), 20, brush );
  16. painter->fillRect(0,0, 30, _size.height() , brush);
  17. painter->setPen(QColor(0,0,0));
  18. for( int x = 30; x<= _size.width();x+=80 ) {
  19. painter->drawLine( x, 0, x, _size.height() );
  20. }
  21. for( int y = 20; y <= _size.height(); y+=20){
  22. painter->drawLine(0, y, _size.width(), y );
  23. }
  24. }
  25.  
  26. /*void mytable::drawHeaders( QPainter* painter, QSize _size ) {
  27.  
  28. }*/
  29. int main( int argc, char** argv) {
  30. QApplication app( argc, argv );
  31. w.setGeometry(0,0,600,600);
  32. mytable table( &w );
  33. table.setGeometry(0,0,600,600);
  34. w.show();
  35. return app.exec();
  36. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //mytable.h
  2. #ifndef MYTABLE_H
  3. #define MYTABLE_H
  4.  
  5. #include <QtGui/QWidget>
  6. #include <QtGui/QPainter>
  7.  
  8. class mytable : public QWidget {
  9.  
  10. public:
  11. mytable(QWidget*);
  12. protected:
  13. void paintEvent( QPaintEvent* );
  14. void drawHeaders(QPainter*, QSize );
  15.  
  16. };
To copy to clipboard, switch view to plain text mode 

Compiling works fine, but if i run, the widget shows up, but i get the following error
if i resize the widget:
Qt Code:
  1. QPixmap::operator=: Cannot assign to pixmap during painting
To copy to clipboard, switch view to plain text mode 

And this error if i close the widget:
Qt Code:
  1. QPaintDevice: Cannot destroy paint device that is being painted
To copy to clipboard, switch view to plain text mode 

What can i do to solve this errors?

regards, hannesvdc