当前位置: 首页>>代码示例>>C++>>正文


C++ QAbstractItemModel::disconnect方法代码示例

本文整理汇总了C++中QAbstractItemModel::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemModel::disconnect方法的具体用法?C++ QAbstractItemModel::disconnect怎么用?C++ QAbstractItemModel::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAbstractItemModel的用法示例。


在下文中一共展示了QAbstractItemModel::disconnect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: refreshJsonTree

void JsonEditorMain::refreshJsonTree()
{
    if (!ui->jsonCode->document()->isEmpty())
    {
        QByteArray ss = ui->jsonCode->toPlainText().toLocal8Bit();
        std::string json = ui->jsonCode->toPlainText().toStdString();
        Json::Reader jsonReader;
        jsonValue.clear();
        jsonReader.parse(ss.data(), jsonValue);

        QStringList headers;
        headers << treeViewColumnKey << treeViewColumnValue << treeViewColumnType;



        QAbstractItemModel *oldModel = ui->jsonTree->model();
        if (oldModel != NULL)
            oldModel->disconnect(SIGNAL(dataChanged(QModelIndex,QModelIndex)));

        JsonTreeModel *model = new JsonTreeModel(headers, jsonValue);
        QItemSelectionModel *selectionModel = ui->jsonTree->selectionModel();
        connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(treeViewDataChanged()));
        ui->jsonTree->setModel(model);
        ui->jsonTree->reset();
        delete selectionModel;
        delete oldModel;


        ui->jsonTree->expandAll();

        for (int i = 0; i < ui->jsonTree->model()->columnCount(); i++)
            ui->jsonTree->resizeColumnToContents(i);
    }
}
开发者ID:peteristhegreat,项目名称:qt-json-editor,代码行数:34,代码来源:jsoneditormain.cpp

示例2: setSourceModel

	// *** TreeChainsawFilter ***
	void TreeChainsawFilter::setSourceModel(QAbstractItemModel *sourceModel)
	{
		QAbstractItemModel* oldSource = this->sourceModel();
		if (oldSource)
			oldSource->disconnect(this);
		QAbstractProxyModel::setSourceModel(sourceModel);
		connect(sourceModel, SIGNAL(modelReset()), this, SLOT(resetInternalData()));
		sort(0, Qt::AscendingOrder);
	}
开发者ID:aseba-community,项目名称:aseba,代码行数:10,代码来源:ModelAggregator.cpp

示例3: setSource

void BooksCoverModel::setSource(QObject* aSrc)
{
    QAbstractItemModel* oldM = sourceModel();
    if (aSrc != oldM) {
        const int oldCount = count();
        if (oldM) {
            BooksShelf* oldShelf = qobject_cast<BooksShelf*>(oldM);
            if (oldShelf) {
                const int n = oldShelf->count();
                for (int i=0; i<n; i++) {
                    onBookRemoved(oldShelf->bookAt(i));
                }
            }
            oldM->disconnect(this);
        }
        if (aSrc) {
            QAbstractItemModel* newM = qobject_cast<QAbstractItemModel*>(aSrc);
            if (newM) {
                setSourceModel(newM);
                BooksShelf* newShelf = qobject_cast<BooksShelf*>(newM);
                if (newShelf) {
                    const int n = newShelf->count();
                    for (int i=0; i<n; i++) {
                        onBookAdded(newShelf->bookAt(i));
                    }
                    connect(newShelf,
                        SIGNAL(bookAdded(BooksBook*)),
                        SLOT(onBookAdded(BooksBook*)));
                    connect(newShelf,
                        SIGNAL(bookRemoved(BooksBook*)),
                        SLOT(onBookRemoved(BooksBook*)));
                }
                connect(newM,
                    SIGNAL(rowsInserted(QModelIndex,int,int)),
                    SIGNAL(countChanged()));
                connect(newM,
                    SIGNAL(rowsRemoved(QModelIndex,int,int)),
                    SIGNAL(countChanged()));
                connect(newM,
                    SIGNAL(modelReset()),
                    SIGNAL(countChanged()));
            } else {
                HDEBUG("unexpected source" << aSrc);
                setSourceModel(NULL);
            }
        } else {
            setSourceModel(NULL);
        }
        if (oldCount != count()) {
            Q_EMIT countChanged();
        }
    }
}
开发者ID:alinelena,项目名称:harbour-books,代码行数:53,代码来源:BooksCoverModel.cpp

示例4:

/**
 * @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();
    }
}
开发者ID:fer-rum,项目名称:q2d,代码行数:25,代码来源:MainWindow.cpp

示例5: removeTable

void ChartProxyModel::removeTable(Table *table)
{
    QAbstractItemModel *model = table->model();
    model->disconnect(this);
}
开发者ID:KDE,项目名称:calligra,代码行数:5,代码来源:ChartProxyModel.cpp


注:本文中的QAbstractItemModel::disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。