I am trying to connect a signal to a slot. The project compiles fine, but at runtime I get this error:
QObject::connect: No such slot QHeaderView::onFilterAdded(int)
here is my code:
class MySortFilterProxyModel: public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit MySortFilterProxyModel(QObject *parent = 0);
~MySortFilterProxyModel();
void addFilter(int col, SteFilter *pFilter);
void removeFilter(int col);
signals:
void filterAdded(int);
void filterRemoved(int);
}
class MyHeaderView: public QHeaderView
{
public:
MyHeaderView();
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
public slots:
void onFilterAdded(int);
void onFilterRemoved(int);
private:
QList<int> m_listFilters;
};
I use this line of code to connect the signal to the slot:
QObject::connect(&m_proxyModel, SIGNAL(filterAdded(int)), &m_headerView, SLOT(onFilterAdded(int)));
m_proxyModel is of type MySortFilterProxyModel and m_headerView is of type MyHeaderView. They are not pointers.
I don't get why this happens. I have connected other signals and slots using the same technique and had no problems. Any help would be appreciated, thanks.