22  connect( addButton, &QToolButton::clicked, 
this, &QgsTableWidgetBase::addButton_clicked );
 
   23  connect( removeButton, &QToolButton::clicked, 
this, &QgsTableWidgetBase::removeButton_clicked );
 
   28  tableView->setModel( model );
 
   29  connect( tableView->selectionModel(), &QItemSelectionModel::selectionChanged, 
this, &QgsTableWidgetBase::onSelectionChanged );
 
   35void QgsTableWidgetBase::addButton_clicked()
 
   37  const QItemSelectionModel *select = tableView->selectionModel();
 
   38  const int pos = select->hasSelection() ? select->selectedRows()[0].row() : 0;
 
   39  QAbstractItemModel *model = tableView->model();
 
   40  model->insertRows( pos, 1 );
 
   41  const QModelIndex index = model->index( pos, 0 );
 
   42  tableView->scrollTo( index );
 
   43  tableView->edit( index );
 
   44  tableView->selectRow( pos );
 
   47void QgsTableWidgetBase::removeButton_clicked()
 
   49  const QItemSelectionModel *select = tableView->selectionModel();
 
   51  if ( select->hasSelection() )
 
   53    tableView->model()->removeRows( select->selectedRows()[0].row(), 1 );
 
   57void QgsTableWidgetBase::onSelectionChanged()
 
   59  removeButton->setEnabled( tableView->selectionModel()->hasSelection() );