本文整理汇总了C++中QAbstractItemModel::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::deleteLater方法的具体用法?C++ QAbstractItemModel::deleteLater怎么用?C++ QAbstractItemModel::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemModel
的用法示例。
在下文中一共展示了QAbstractItemModel::deleteLater方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rowsAboutToBeRemoved
void NickListWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
Q_ASSERT(model());
if(!parent.isValid()) {
// ok this means that whole networks are about to be removed
// we can't determine which buffers are affect, so we hope that all nets are removed
// this is the most common case (for example disconnecting from the core or terminating the clint)
NickView *nickView;
QHash<BufferId, NickView *>::iterator iter = nickViews.begin();
while(iter != nickViews.end()) {
nickView = *iter;
iter = nickViews.erase(iter);
ui.stackedWidget->removeWidget(nickView);
QAbstractItemModel *model = nickView->model();
nickView->setModel(0);
if(QSortFilterProxyModel *filter = qobject_cast<QSortFilterProxyModel *>(model))
filter->setSourceModel(0);
model->deleteLater();
nickView->deleteLater();
}
} else {
// check if there are explicitly buffers removed
for(int i = start; i <= end; i++) {
QVariant variant = parent.child(i,0).data(NetworkModel::BufferIdRole);
if(!variant.isValid())
continue;
BufferId bufferId = qVariantValue<BufferId>(variant);
removeBuffer(bufferId);
}
}
}
示例2: exec
bool CoaToolsSqlBrowser::exec()
{
BEGIN;
if (m_isValid != true) RETURN(false);
CoaSqlQueryModel *model = new CoaSqlQueryModel(m_table);
CoaSqlQuery query(m_connectionWidget->currentDatabase());
query.execChecked(m_sqlEdit->toPlainText());
model->setQuery(query);
QAbstractItemModel *oldmodel = m_table->model();
m_table->setModel(model);
if (oldmodel != 0) oldmodel->deleteLater();
m_table->reset();
if (model->lastError().type() != QSqlError::NoError){
emit statusMessage(model->lastError().text());
RETURN(false);
} else if (model->query().isSelect()) {
emit statusMessage(tr("Query OK."));
RETURN(true);
} else {
emit statusMessage(tr("Query OK, number of affected rows: %1").arg(model->query().numRowsAffected()));
RETURN(true);
}
}
示例3: pluginSelected
void ctkPluginBrowser::pluginSelected(const QModelIndex &index)
{
QVariant v = index.data(Qt::UserRole);
QSharedPointer<ctkPlugin> plugin = framework->getPluginContext()->getPlugin(v.toLongLong());
if (!plugin) return;
updatePluginToolbar(plugin);
QAbstractItemModel* oldModel = ui.pluginResourcesTreeView->model();
ui.pluginResourcesTreeView->setModel(new ctkPluginResourcesTreeModel(plugin, this));
if (oldModel) oldModel->deleteLater();;
}
示例4: removeBuffer
void NickListWidget::removeBuffer(BufferId bufferId) {
if(!nickViews.contains(bufferId))
return;
NickView *view = nickViews.take(bufferId);
ui.stackedWidget->removeWidget(view);
QAbstractItemModel *model = view->model();
view->setModel(0);
if(QSortFilterProxyModel *filter = qobject_cast<QSortFilterProxyModel *>(model))
filter->setSourceModel(0);
model->deleteLater();
view->deleteLater();
}
示例5:
/**
* @brief MainWindow::setDocumentModel
*
* Will be called whe a new q2d::Project is created, to link the projects
* document model with the appropriate list view in the UI.
* @param model
*/
void
MainWindow::slot_setDocumentModel(QStandardItemModel* model) {
// close all tabs related to the old model
m_ui->schematicsTabWidget->clear();
QListView* documentView = m_ui->documentListView;
documentView->clearSelection();
QAbstractItemModel* oldModel = documentView->model();
m_ui->documentListView->setModel(model);
if (oldModel != nullptr) {
oldModel->disconnect();
oldModel->deleteLater();
}
}
示例6: slotShowTable
void CoaToolsSqlBrowser::slotShowTable(const CoaString &t)
{
BEGIN;
if (m_isValid != true) return;
INF(CoaString("Show Table %1").arg(t));
CoaSqlTableModel *model = new CoaSqlTableModel(m_table, m_connectionWidget->currentDatabase());
model->setTable(t);
model->select();
if (model->lastError().type() != QSqlError::NoError)
emit statusMessage(model->lastError().text());
QAbstractItemModel *oldmodel = m_table->model();
m_table->setModel(model);
if (oldmodel != 0) oldmodel->deleteLater();
}