Hi there - I have created a class that extends QTableView. When the user changes which items are selected in the view, I would expect that the class would send a selectionChanged signal. However, I cannot seem to connect that signal to a slot. I am pretty sure that my syntax is correct, but I must be doing something wrong since it's not working.
Qt Code:
  1. // gridview.h
  2. #ifndef GRIDVIEW_H
  3. #define GRIDVIEW_H
  4.  
  5. #include <QTableView>
  6. #include <QHeaderView>
  7. #include <QItemSelection>
  8. #include <QItemSelectionModel>
  9.  
  10. class GridView : public QTableView
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. GridView(QWidget *parent = 0);
  16. ~GridView();
  17. private slots:
  18. void testSlot(const QItemSelection &selected, const QItemSelection &deselected);
  19. };
  20.  
  21. #endif // GRIDVIEW_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. // gridview.cpp
  2. #include "gridview.h"
  3.  
  4. GridView::GridView(QWidget *parent)
  5. : QTableView(parent)
  6. {
  7. connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)), this, SLOT(testSlot(const QItemSelection &selected, const QItemSelection &deselected)));
  8. }
  9.  
  10. GridView::~GridView() { }
  11.  
  12. void GridView::testSlot(const QItemSelection &selected, const QItemSelection &deselected)
  13. {
  14. // my code here never gets called...
  15. }
To copy to clipboard, switch view to plain text mode 

Any help is appreciated. Thanks in advance.

Jimmy