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.
// gridview.h
#ifndef GRIDVIEW_H
#define GRIDVIEW_H
#include <QTableView>
#include <QHeaderView>
#include <QItemSelection>
#include <QItemSelectionModel>
{
Q_OBJECT
public:
~GridView();
private slots:
};
#endif // GRIDVIEW_H
// gridview.h
#ifndef GRIDVIEW_H
#define GRIDVIEW_H
#include <QTableView>
#include <QHeaderView>
#include <QItemSelection>
#include <QItemSelectionModel>
class GridView : public QTableView
{
Q_OBJECT
public:
GridView(QWidget *parent = 0);
~GridView();
private slots:
void testSlot(const QItemSelection &selected, const QItemSelection &deselected);
};
#endif // GRIDVIEW_H
To copy to clipboard, switch view to plain text mode
// gridview.cpp
#include "gridview.h"
GridView
::GridView(QWidget *parent
){
}
GridView::~GridView() { }
{
// my code here never gets called...
}
// gridview.cpp
#include "gridview.h"
GridView::GridView(QWidget *parent)
: QTableView(parent)
{
connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)), this, SLOT(testSlot(const QItemSelection &selected, const QItemSelection &deselected)));
}
GridView::~GridView() { }
void GridView::testSlot(const QItemSelection &selected, const QItemSelection &deselected)
{
// my code here never gets called...
}
To copy to clipboard, switch view to plain text mode
Any help is appreciated. Thanks in advance.
Jimmy
Bookmarks