Thanks for advice. I choose solution 1. I post it here so somebody else could use it .
mainwindow.h
Qt Code:
  1. class my_table : public QTableWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. my_table(int row, int col, QWidget *parent = 0);
  7. ~my_table();
  8.  
  9. private:
  10.  
  11.  
  12. private slots:
  13. void selectAll ();
  14. };
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent)
  2. : QMainWindow(parent), ui(new Ui::MainWindow)
  3. {
  4. ui->setupUi(this);
  5.  
  6. my_table *table = new my_table(2,2,this);
  7. table->setGeometry(10,20,250,190);
  8.  
  9.  
  10. }
  11.  
  12. MainWindow::~MainWindow()
  13. {
  14. delete ui;
  15. }
  16.  
  17. my_table::my_table(int row, int col, QWidget *parent)
  18. : QTableWidget(row, col, parent)
  19. {
  20.  
  21. }
  22.  
  23. my_table::~my_table()
  24. {
  25.  
  26. }
  27.  
  28. void my_table::selectAll(void)
  29. {
  30. qDebug() << "select";
  31. }
To copy to clipboard, switch view to plain text mode 

Thanks