Thanks for your help! I tried to make a test program with a qtablewidget, but did not work! I created an UI with a QWidget a
I created a derived class from QTableWidget and override mousePressedEvent. When i click on the table nothing happens. I believe this is happening because i didn't call mousePressedEvent anywhere, but i don't know where to call it.

Take a look at the code, please. What is wrong?

Qt Code:
  1. #ifndef TESTEVT_H
  2. #define TESTEVT_H
  3.  
  4. #include <iostream>
  5. #include <QMouseEvent>
  6. #include <QTableWidget>
  7.  
  8. using namespace std;
  9.  
  10. class TestEvt : public QTableWidget {
  11.  
  12. public:
  13. TestEvt( );
  14. virtual void mousePressEvent(QMouseEvent *event);
  15. };
  16.  
  17. #endif // TESTEVT_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #include "testevt.h"
  2.  
  3. TestEvt::TestEvt( ) {
  4. cout << "Object created." << endl;
  5. }
  6.  
  7. void TestEvt::mousePressEvent(QMouseEvent *event) {
  8. if(event->button( ) == Qt::LeftButton)
  9. cout << "Left Button Clicked." << endl;
  10. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow {
  11. Q_OBJECT
  12.  
  13. public:
  14. explicit MainWindow(QWidget *parent = 0);
  15. ~MainWindow( );
  16.  
  17. private:
  18. Ui::MainWindow *ui;
  19. };
  20.  
  21. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #include "mainwindow.h"
  2. #include "testevt.h"
  3. #include "ui_mainwindow.h"
  4.  
  5. MainWindow::MainWindow(QWidget *parent) : QMainWindow( parent ), ui(new Ui::MainWindow) {
  6. ui->setupUi( this );
  7. TestEvt evt;
  8. }
  9.  
  10. MainWindow::~MainWindow( ) {
  11. delete ui;
  12. }
To copy to clipboard, switch view to plain text mode