Reputation: 175
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
Upvotes: 4
Views: 2413
Reputation: 27629
As you can see from the definition of rowCountChanged: -
void QTableView::rowCountChanged(int oldCount, int newCount) [protected slot]
This is a protected slot, so the error that you're seeing 'No such signal' is correct. What you're probably needing to do is check for a change in the model data that is attached to the QTableView.
Upvotes: 1
Reputation: 2017
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(...);
}
Upvotes: 4