{
spinBoxDelegar = new spinBoxDelegate(this);
excluirButton
= new QPushButton(*iconeExcluirButton,
"",
0);
excluirButton->setStyleSheet("background-color: rgb(255, 255, 255); color: rgb(255, 255, 255); border: 0");
modelo->insertRow(modelo->rowCount());
modelo->setData(modelo->index(modelo->rowCount()-1,1), 1);
tabela->setItemDelegateForColumn(1, spinBoxDelegar);
tabela->setIndexWidget(modelo->index(modelo->rowCount()-1,2), excluirButton);
tabela->edit(modelo->index(modelo->rowCount()-1,0));
mapearSinalBotaoExcluir->setMapping(excluirButton, modelo->rowCount()-1);
connect(excluirButton, SIGNAL(clicked()), mapearSinalBotaoExcluir, SLOT(map()));
connect(mapearSinalBotaoExcluir, SIGNAL(mapped(int)), this, SLOT(on_excluir_clicked(int)));
}
void MainWindow::on_excluir_clicked(int linha)
{
this->modelo1->removeRow(linha);
}
void MainWindow::adicionarLinha(QStandardItemModel *modelo, QTableView *tabela)
{
spinBoxDelegar = new spinBoxDelegate(this);
QPushButton *excluirButton = new QPushButton(*iconeExcluirButton, "", 0);
excluirButton = new QPushButton(*iconeExcluirButton, "", 0);
excluirButton->setStyleSheet("background-color: rgb(255, 255, 255); color: rgb(255, 255, 255); border: 0");
QSignalMapper *mapearSinalBotaoExcluir = new QSignalMapper(this);
modelo->insertRow(modelo->rowCount());
modelo->setData(modelo->index(modelo->rowCount()-1,1), 1);
tabela->setItemDelegateForColumn(1, spinBoxDelegar);
tabela->setIndexWidget(modelo->index(modelo->rowCount()-1,2), excluirButton);
tabela->edit(modelo->index(modelo->rowCount()-1,0));
mapearSinalBotaoExcluir->setMapping(excluirButton, modelo->rowCount()-1);
connect(excluirButton, SIGNAL(clicked()), mapearSinalBotaoExcluir, SLOT(map()));
connect(mapearSinalBotaoExcluir, SIGNAL(mapped(int)), this, SLOT(on_excluir_clicked(int)));
}
void MainWindow::on_excluir_clicked(int linha)
{
this->modelo1->removeRow(linha);
}
To copy to clipboard, switch view to plain text mode
Bookmarks