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


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

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


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

示例1: setupModel

void LogDetailWidget::setupModel()
{
	QAbstractItemModel *model = pieChart->model();

	model->setHeaderData(0, Qt::Horizontal, tr("Label"));
    model->setHeaderData(1, Qt::Horizontal, tr("Quantity"));

	QString colors[] = {"#ff0000", "#00ff00", "#0000ff","#ffff00", "#ff00ff", "#00ffff", "#000000", "#ffffff", "#777777", "#222222", "#aaaaaa"};

	int i=0;
	for(hash_map<string, double>::iterator it = logMan.process_stat.begin() ; it != logMan.process_stat.end(); it++)
	{
		string process = it->first;
		double duration = it->second;

		model->insertRow(i);
		model->setData(model->index(i, 0), QString::fromStdString(process));
		model->setData(model->index(i, 1), duration);

		model->setData(model->index(i, 0, QModelIndex()),
                           QColor(colors[i]), Qt::DecorationRole);
		i++;
	}

}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:25,代码来源:logdetailwidget.cpp

示例2: insertRow

void MetaEditor::insertRow(QString code, QString contents)
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    // force all row insertions to be children of the root item
    while(index.parent() != QModelIndex()) {
        index = index.parent();
    }

    if (!model->insertRow(index.row()+1, index.parent()))
        return;


    updateActions();

    QModelIndex child = model->index(index.row()+1, 0, index.parent());
    model->setData(child, QVariant(code), Qt::EditRole);
    for (int column = 1; column < model->columnCount(index.parent()); ++column) {
        QModelIndex nchild = model->index(index.row()+1, column, index.parent());
        if (!contents.isEmpty()) {
            model->setData(nchild, QVariant(contents), Qt::EditRole);
        } else {
            model->setData(nchild, QVariant(tr("[Your value here]")), Qt::EditRole);
        }
    }

    // force newly inserted row to be the currently selected item so that any
    // follow-on insertChild calls use this as their parent.
    view->selectionModel()->setCurrentIndex(child, QItemSelectionModel::ClearAndSelect);
    updateActions();
}
开发者ID:Sigil-Ebook,项目名称:Sigil,代码行数:32,代码来源:MetaEditor.cpp

示例3: addEntry

void EmoticonViewer::addEntry()
{
    QAbstractItemModel *model = _ui->listView->model();
    int row = model->rowCount();
    model->insertRow(row);
    _ui->listView->edit(model->index(row, 0));
}
开发者ID:Brli,项目名称:Qelly,代码行数:7,代码来源:EmoticonViewer.cpp

示例4: 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);
    }
}
开发者ID:overloop,项目名称:insertremovepanel,代码行数:25,代码来源:insertremove_button.cpp

示例5: insertChild

void MainWindow::insertChild()
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    if (model->columnCount(index) == 0) {
        if (!model->insertColumn(0, index))
            return;
    }

    if (!model->insertRow(0, index))
        return;

    for (int column = 0; column < model->columnCount(index); ++column) {
        QModelIndex child = model->index(0, column, index);
        model->setData(child, QVariant("[No data]"), Qt::EditRole);
        if (!model->headerData(column, Qt::Horizontal).isValid())
            model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"),
                                 Qt::EditRole);
    }

    view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
                                            QItemSelectionModel::ClearAndSelect);
    updateActions();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:25,代码来源:mainwindow.cpp

示例6: insert

void PlacesDialog::insert()
{
  QItemSelectionModel *selection = tableView->selectionModel();
  int row = selection->selectedIndexes().first().row();

  QAbstractItemModel *model = tableView->model();
  QModelIndex index = model->index(row, Place_Text);
  model->insertRow(row+1);

  tableView->setCurrentIndex(index);
}
开发者ID:ukv626,项目名称:cards2,代码行数:11,代码来源:placesdialog.cpp

示例7: appendTableViewRow

void UiUtil::appendTableViewRow(QTableView *view, int editColumn) {
    QAbstractItemModel *model = view->model();
    int row = model->rowCount();
    model->insertRow(row);

    QModelIndex index = model->index(row, editColumn);
    if (!index.isValid()) { return; }

    view->setCurrentIndex(index);
    view->edit(index);
}
开发者ID:xtuer,项目名称:Qt,代码行数:11,代码来源:UiUtil.cpp

示例8: on_btnAddBeat_clicked

void WindowAnotationManager::on_btnAddBeat_clicked()
{
    VideoDataClip *clip = ui->widgetStrainVideo->getClip();
    if (!clip || clip->size() == 0) return;

    int beat = ui->widgetStrainVideo->getCurrentIndex();

    QAbstractItemModel *model = ui->listViewBeats->model();
    int rowCount = model->rowCount();
    model->insertRow(rowCount);
    QModelIndex index = model->index(rowCount, 0);
    model->setData(index, beat);
}
开发者ID:stepanmracek,项目名称:icrc,代码行数:13,代码来源:windowanotationmanager.cpp

示例9: addNode

void TracingLegend::addNode(NodeFacade* node)
{
    int row = rows_.size();
    rows_.push_back(node);

    QAbstractItemModel* m = model();
    m->insertRow(row);
    m->setData(m->index(row, 0), QString::fromStdString(node->getLabel()));

    resizeToFit();

    Q_EMIT nodeAdded(node);
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:13,代码来源:tracing_legend.cpp

示例10: newRow

void ServicesDialog::newRow()
{
  // QItemSelectionModel *selection = tableView->selectionModel();
  // int row = selection->selectedIndexes().first().row();

  QAbstractItemModel *model = tableView->model();
  // QModelIndex index = model->index(0, ServicesModel::Text);
  model->insertRow(model->rowCount());
  // model->setData(model->index(row +1, ServicesModel::Type), 0);
  // model->submit();

  // tableView->setCurrentIndex(index);
}
开发者ID:ukv626,项目名称:abonent2,代码行数:13,代码来源:ServicesDialog.cpp

示例11: insertRow

void MainWindow::insertRow()
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();

    if (!model->insertRow(index.row()+1, index.parent()))
        return;

    updateActions();

    for (int column = 0; column < model->columnCount(index.parent()); ++column) {
        QModelIndex child = model->index(index.row()+1, column, index.parent());
        model->setData(child, QVariant("[No data]"), Qt::EditRole);
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:mainwindow.cpp

示例12: addMedia

void ScreenTab::addMedia()
{
    QAbstractItemModel *mediaModel = ui->mediaListTableView->model();
    if (!mediaModel)
        return;
    QStringList newMediaFilePatchList = QFileDialog::getOpenFileNames(this, tr("Select media"), QString());
    if (newMediaFilePatchList.isEmpty())
        return;
    int currentRow = getCurrentMediaTableRow();
    foreach (QString newMediaFilePatch, newMediaFilePatchList)
    {
        if (currentRow == -1)
            currentRow = mediaModel->rowCount() - 1;
        mediaModel->insertRow(currentRow + 1);
        mediaModel->setData(mediaModel->index(currentRow + 1, MediaTableModel::FilePatch), newMediaFilePatch);
    }
    ui->mediaListTableView->selectRow(currentRow + 1);
}
开发者ID:0x6368656174,项目名称:iqMultipleDesktopVideo,代码行数:18,代码来源:screentab.cpp

示例13: classifyAction

void LogDetailWidget::classifyAction()
{
	QAbstractItemModel *model = new QStandardItemModel(0, 6, this);
	ui.aaView->setModel(model);

	int k = 0;
	model->setHeaderData(k++, Qt::Horizontal, tr("Timestamp"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Application"));
	model->setHeaderData(k++, Qt::Horizontal, tr("GUI Component"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Name"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Type"));
	model->setHeaderData(k++, Qt::Horizontal, tr("Control Value"));

	string eclipseStatus = "normal"; //normal edit; run or debug configuration; debug model; 
	int temp;
	int num = 0;
	for(int i=0; i<logMan.events.size(); i++)
	{
		LogEvent e = logMan.events[i];
		if(!e.isHasAcc) continue;

		model->insertRow(num);

		k = 0;
		model->setData(model->index(num,k++), QString::fromStdString(e.timestamp));
		model->setData(model->index(num,k++), QString::fromStdString(e.processName));
		
		if(e.acc.type == "menu item" || e.acc.type == "tab item" 
			|| e.acc.parent_name == "Desktop" || e.acc.parent_name == "%trimmedwindow.label.eclipseSDK")
		{
			model->setData(model->index(num,k++), QString::fromStdString(e.acc.name));
		}
		else
		{
			model->setData(model->index(num,k++), QString::fromStdString(e.acc.parent_name));
		}
		
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.name));
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.type));
		model->setData(model->index(num,k++), QString::fromStdString(e.acc.value));
		num++;

	}
}
开发者ID:baolingfeng,项目名称:HCICollectTool,代码行数:44,代码来源:logdetailwidget.cpp

示例14: slotInsertRowPressed

void TableEditorDialog::slotInsertRowPressed()
{
    Q_ASSERT( m_tableView->model() );

    QAbstractItemModel *model = m_tableView->model();
    QModelIndex         currIndex = m_tableView->currentIndex();

    int selectedRow;
    if ( model->rowCount() == 0 )
        // +1 is added below.
        selectedRow = -1;
    else if ( currIndex.isValid() )
        selectedRow = currIndex.row();
    else
        selectedRow = m_tableView->model()->rowCount() - 1;

    // Insert the row *after* the selection, thus +1
    model->insertRow( selectedRow + 1 );
}
开发者ID:KDE,项目名称:calligra,代码行数:19,代码来源:TableEditorDialog.cpp

示例15: loadPreviewPlugins

void PreviewsSettingsPage::loadPreviewPlugins()
{
    QAbstractItemModel* model = m_listView->model();

    const KService::List plugins = KServiceTypeTrader::self()->query(QLatin1String("ThumbCreator"));
    foreach (const KSharedPtr<KService>& service, plugins) {
        const bool configurable = service->property("Configurable", QVariant::Bool).toBool();
        const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName());

        model->insertRow(0);
        const QModelIndex index = model->index(0, 0);
        model->setData(index, show, Qt::CheckStateRole);
        model->setData(index, configurable, ServiceModel::ConfigurableRole);
        model->setData(index, service->name(), Qt::DisplayRole);
        model->setData(index, service->desktopEntryName(), ServiceModel::DesktopEntryNameRole);
    }

    model->sort(Qt::DisplayRole);
}
开发者ID:theunbelievablerepo,项目名称:dolphin2.1,代码行数:19,代码来源:previewssettingspage.cpp


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