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 );
 
   33 void QgsTableWidgetBase::addButton_clicked()
 
   35   const QItemSelectionModel *select = tableView->selectionModel();
 
   36   const int pos = select->hasSelection() ? select->selectedRows()[0].row() : 0;
 
   37   QAbstractItemModel *model = tableView->model();
 
   38   model->insertRows( pos, 1 );
 
   39   const QModelIndex index = model->index( pos, 0 );
 
   40   tableView->scrollTo( index );
 
   41   tableView->edit( index );
 
   42   tableView->selectRow( pos );
 
   45 void QgsTableWidgetBase::removeButton_clicked()
 
   47   const QItemSelectionModel *select = tableView->selectionModel();
 
   49   if ( select->hasSelection() )
 
   51     tableView->model()->removeRows( select->selectedRows()[0].row(), 1 );
 
   55 void QgsTableWidgetBase::onSelectionChanged()
 
   57   removeButton->setEnabled( tableView->selectionModel()->hasSelection() );