how to connect rowCountChanged to a slot

qt, qtablewidget

Solution

As merlin said, Thats a protected slot.

But you can ask for the underlying model:

(Since widget inherits from tableView which inherits from AbstractView)

QAbstractItemModel * QAbstractItemView::model () const

And connect to model signals:

void QAbstractItemModel::rowsInserted ( const QModelIndex & parent, int start, int end ) [signal]
void QAbstractItemModel::rowsRemoved ( const QModelIndex & parent, int start, int end ) [signal]

Here You got all model signals

In fact, there is another way i would explore:

Subclassing QTableWidget, (public) you will have access to that protected slot.

So, creating your own signal:

void YourTableWidget::rowCountChanged(int,int)
{
QTableWidget::rowCountChanged(int,int);
emit your_signal(...);

}

Problem

here is what i tend to design: when the tablewidget changes(say its rowcount), the label will show the rowcount.But when i tried it, Qtcreator says: `Object::connect: No such signal QTableWidget::rowCountChanged(int,int) in ..\ui\mainwindow.cpp:55` why? rowCountChanged(int, int) is one slot inherited from QTableView, i think... Thanks

Original source