Q_OBJECT
public slots:
void onRowsNuberChanged();
};
...
connect(ui
->tableView
->model
(),
SIGNAL(rowsInserted
(QModelIndex,
int,
int)),
this,
SLOT(onRowsNuberChanged
()));
connect(ui
->tableView
->model
(),
SIGNAL(rowsRemoved
(QModelIndex,
int,
int)),
this,
SLOT(onRowsNuberChanged
()));
}
void MyMainWindow::onRowsNuberChanged() {
int rowsCount = ui->tableView->model()->rowCount();
// do whatever you need
...
}
class MyMainWindow : public QMainWindow {
Q_OBJECT
public slots:
void onRowsNuberChanged();
};
MyMainWindow::MyMainWindow(QWidget *parent) : QMainWindow(parent) {
...
connect(ui->tableView->model(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(onRowsNuberChanged()));
connect(ui->tableView->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(onRowsNuberChanged()));
}
void MyMainWindow::onRowsNuberChanged() {
int rowsCount = ui->tableView->model()->rowCount();
// do whatever you need
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks