本文整理汇总了C++中QAbstractItemModel::removeRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::removeRow方法的具体用法?C++ QAbstractItemModel::removeRow怎么用?C++ QAbstractItemModel::removeRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::removeRow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_clicked
void Button::on_clicked()
{
QTableView* table = qobject_cast<QTableView*>(this->parent());
if (!table)
return;
QAbstractItemModel* model = table->model();
if (!model)
return;
if (_type == InsertRemove::Insert)
{
if (_orientation == Qt::Horizontal)
model->insertColumn(_modelIndex);
else
model->insertRow(_modelIndex);
}
else // _type == InsertRemove::Remove
{
if (_orientation == Qt::Horizontal)
model->removeColumn(_modelIndex);
else
model->removeRow(_modelIndex);
}
}
示例2: removeRow
void MainWindow::removeRow()
{
QModelIndex index = view->selectionModel()->currentIndex();
QAbstractItemModel *model = view->model();
if (model->removeRow(index.row(), index.parent()))
updateActions();
}
示例3: deleteRow
void PageScheme::deleteRow()
{
int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
if (selectScheme->currentIndex() < numberOfDefaultSchemes)
{
QMessageBox deniedMsg(this);
deniedMsg.setIcon(QMessageBox::Warning);
deniedMsg.setWindowTitle(QMessageBox::tr("Schemes - Warning"));
deniedMsg.setText(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText()));
deniedMsg.setWindowModality(Qt::WindowModal);
deniedMsg.exec();
}
else
{
QMessageBox reallyDeleteMsg(this);
reallyDeleteMsg.setIcon(QMessageBox::Question);
reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Schemes - Are you sure?"));
reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the game scheme '%1'?").arg(selectScheme->currentText()));
reallyDeleteMsg.setWindowModality(Qt::WindowModal);
reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
if (reallyDeleteMsg.exec() == QMessageBox::Ok)
{
QAbstractItemModel * model = mapper->model();
model->removeRow(selectScheme->currentIndex());
}
}
}
示例4: OnConvertButtonClicked
void MainWindow::OnConvertButtonClicked()
{
QAbstractItemModel *model = ui->listView->model();
if (!model || model->rowCount() == 0)
{
return;
}
while (model->rowCount())
{
QString pvrName = model->data(model->index(0, 0)).toString();
QString pngName = pvrName;
pngName.replace(".pvr", ".png", Qt::CaseInsensitive);
unsigned char* data;
unsigned long int size;
PVRTHeader header;
int ret = LoadPVRFromFile(pvrName.toUtf8().data(), &data, &size, &header);
if (ret)
{
QFile file(pngName);
file.open(QIODevice::WriteOnly);
QImage image(data, header.width, header.height, QImage::Format_RGBA8888);
QPixmap pixmap = QPixmap::fromImage(image);
pixmap.save(&file, "PNG");
free(data);
}
model->removeRow(0);
}
ui->statusBar->showMessage("Done!");
}
示例5: deleteTreeNode
void JsonEditorMain::deleteTreeNode()
{
QModelIndex index = ui->jsonTree->selectionModel()->currentIndex();
QAbstractItemModel *model = ui->jsonTree->model();
if (model->removeRow(index.row(), index.parent()))
updateActions();
}
示例6: removeMedia
void ScreenTab::removeMedia()
{
QAbstractItemModel *mediaModel = ui->mediaListTableView->model();
if (!mediaModel)
return;
int currentRow = getCurrentMediaTableRow();
if (currentRow == -1)
return;
mediaModel->removeRow(currentRow);
ui->mediaListTableView->clearSelection();
}
示例7: on_btnRemoveBeat_clicked
void WindowAnotationManager::on_btnRemoveBeat_clicked()
{
VideoDataClip *clip = ui->widgetStrainVideo->getClip();
if (!clip || clip->size() == 0) return;
QAbstractItemModel *model = ui->listViewBeats->model();
QModelIndex modelIndex = ui->listViewBeats->currentIndex();
if (modelIndex.row() < 0) return;
model->removeRow(modelIndex.row());
}
示例8: slotRemoveJob
void KOnlineJobOutbox::slotRemoveJob()
{
QModelIndexList indexes = ui->m_onlineJobView->selectionModel()->selectedRows();
if (indexes.isEmpty())
return;
QAbstractItemModel* model = ui->m_onlineJobView->model();
const int count = indexes.count();
for (int i = count - 1; i >= 0; --i) {
model->removeRow(indexes.at(i).row());
}
}
示例9: learnEntry
void LineEdit::learnEntry()
{
QAbstractItemModel *m = completer()->model();
int rows = m->rowCount();
for (int i = 0; i < rows; ++i) {
if (m->index(i,0).data() == text()) {
m->removeRow(i);
--rows;
break;
}
}
m->insertRows(rows, 1);
m->setData(m->index(rows, 0), text(), Qt::DisplayRole);
m_historyPosition = rows + 1;
}
示例10: removeRow
void PathPlanningWidget::removeRow(int marker_nr)
{
/*! When the user deletes certain Way-Point either from the RViz or the RQT Widget the TreeView needs to delete that particular row and update the state of the TreeWidget.
*/
QAbstractItemModel *model = ui_.treeView->model();
model->removeRow(marker_nr,QModelIndex());
ROS_INFO_STREAM("deleting point nr: "<< marker_nr);
for(int i=marker_nr;i<=model->rowCount();++i)
{
model->setData(model->index((i-1),0,QModelIndex()),QVariant((i-1)),Qt::EditRole);
}
//check how to properly set the selection
ui_.treeView->selectionModel()->setCurrentIndex(model->index((model->rowCount()-1),0,QModelIndex()),QItemSelectionModel::ClearAndSelect);
ui_.txtPointName->setText(QString::number(model->rowCount()-1));
pointRange();
}
示例11: on_actionCut_triggered
// Auto-connected to actionCut's signal triggered()
void MainWindow::on_actionCut_triggered()
{
QWidget *widget = ui->tabWidget->currentWidget();
QTableView *tableView = qobject_cast<QTableView *>(widget);
if (tableView)
{
// QModelIndexList selection = tableView->selectionModel()->selectedIndexes();
// QSet<int> rows;
// Q_FOREACH (QModelIndex index, selection)
// {
// rows.insert(index.row());
// }
// qDebug() << "Removing number of rows:" << rows.size();
QModelIndex index = tableView->currentIndex();
if (!index.isValid())
return;
QAbstractItemModel *model = tableView->model();
Q_ASSERT(model);
model->removeRow(index.row());
}
}