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


C++ QTreeWidgetItem::insertChild方法代码示例

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


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

示例1: on_moveItemRightButton_clicked

void TreeWidgetEditor::on_moveItemRightButton_clicked()
{
    QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
    if (!curItem)
        return;

    int idx, idxCount;
    if (curItem->parent()) {
        idx = curItem->parent()->indexOfChild(curItem);
        idxCount = curItem->parent()->childCount();
    } else {
        idx = ui.treeWidget->indexOfTopLevelItem(curItem);
        idxCount = ui.treeWidget->topLevelItemCount();
    }
    if (idx == idxCount - 1)
        return;

    m_updating = true;

    QTreeWidgetItem *takenItem = 0;
    if (curItem->parent()) {
        QTreeWidgetItem *parentItem = curItem->parent()->child(idx + 1);
        takenItem = curItem->parent()->takeChild(idx);
        parentItem->insertChild(0, takenItem);
    } else {
        QTreeWidgetItem *parentItem = ui.treeWidget->topLevelItem(idx + 1);
        takenItem = ui.treeWidget->takeTopLevelItem(idx);
        parentItem->insertChild(0, takenItem);
    }
    ui.treeWidget->setCurrentItem(takenItem, ui.listWidget->currentRow());

    m_updating = false;
    updateEditor();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:34,代码来源:treewidgeteditor.cpp

示例2: on_moveItemUpButton_clicked

void TreeWidgetEditor::on_moveItemUpButton_clicked()
{
    QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
    if (!curItem)
        return;

    int idx;
    if (curItem->parent())
        idx = curItem->parent()->indexOfChild(curItem);
    else
        idx = ui.treeWidget->indexOfTopLevelItem(curItem);
    if (idx == 0)
        return;

    m_updating = true;

    QTreeWidgetItem *takenItem = 0;
    if (curItem->parent()) {
        QTreeWidgetItem *parentItem = curItem->parent();
        takenItem = parentItem->takeChild(idx);
        parentItem->insertChild(idx - 1, takenItem);
    } else {
        takenItem = ui.treeWidget->takeTopLevelItem(idx);
        ui.treeWidget->insertTopLevelItem(idx - 1, takenItem);
    }
    ui.treeWidget->setCurrentItem(takenItem, ui.listWidget->currentRow());

    m_updating = false;
    updateEditor();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:30,代码来源:treewidgeteditor.cpp

示例3: importToLibrary

void LibraryTreeWidget::importToLibrary()
{
	QTreeWidgetItem* root = invisibleRootItem();

	if (selectedItems().empty() == false)
		root = selectedItems().front();

	QString path = QFileInfo(projectFileName_).path();
	QDir dir(path);

	QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import to Library"), path, tr("All Files (*.*)"));

	QStringList::Iterator it = fileNames.begin();
	while(it != fileNames.end())
	{
		QString fileName = dir.relativeFilePath(*it);

		if (isFileAlreadyImported(fileName))
		{
			QMessageBox::information(this, tr("Gideros"), tr("The file '%1' cannot be added to the library because it is already a member of the library.").arg(fileName));
		}
		else
		{
			QTreeWidgetItem *item = createFileItem(fileName);
			if (root == invisibleRootItem())
				root->addChild(item);
			else
				root->insertChild(0, item);
			root->setExpanded(true);
		}

		++it;
	}
	checkModification();
}
开发者ID:lsouchet,项目名称:gideros,代码行数:35,代码来源:librarytreewidget.cpp

示例4: foreach

    // Add changed/added items:
    foreach (int a, toAdd) {
        BaseQtVersion *version = QtVersionManager::version(a)->clone();
        m_versions.append(version);
        QTreeWidgetItem *item = new QTreeWidgetItem;

        item->setText(0, version->displayName());
        item->setText(1, version->qmakeCommand().toUserOutput());
        item->setData(0, VersionIdRole, version->uniqueId());
        item->setData(0, ToolChainIdRole, defaultToolChainId(version));
        const ValidityInfo info = validInformation(version);
        item->setIcon(0, info.icon);

        // Insert in the right place:
        QTreeWidgetItem *parent = version->isAutodetected()? m_autoItem : m_manualItem;
        for (int i = 0; i < parent->childCount(); ++i) {
            BaseQtVersion *currentVersion = m_versions.at(indexForTreeItem(parent->child(i)));
            if (currentVersion->qtVersion() > version->qtVersion())
                continue;
            parent->insertChild(i, item);
            parent = 0;
            break;
        }

        if (parent)
            parent->addChild(item);
    }
开发者ID:Gardenya,项目名称:qtcreator,代码行数:27,代码来源:qtoptionspage.cpp

示例5: UnwrapTreeItem

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QTreeWidgetItem* FilterLibraryTreeWidget::UnwrapTreeItem(QJsonObject object)
{
    FilterLibraryTreeWidget::ItemType type = FilterLibraryTreeWidget::ItemType(object["Type"].toInt());
    QTreeWidgetItem* item = new QTreeWidgetItem(type);

    QString name = object["Name"].toString();
    item->setText(0, name);
    item->setData(0, Qt::UserRole, name);

    if (type == FilterLibraryTreeWidget::Node_Item_Type)
    {
        item->setIcon(0, QIcon(":/folder_blue.png"));
        item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
        item->setData(2, Qt::UserRole, object["Expanded"].toBool());
        for (QJsonObject::iterator iter = object.begin(); iter != object.end(); ++iter)
        {
            if (iter.value().isObject())
            {
                QJsonObject childObj = iter.value().toObject();
                QTreeWidgetItem* child = FilterLibraryTreeWidget::UnwrapTreeItem(childObj);
                item->insertChild(0, child);
            }
        }
    }
    else
    {
        item->setIcon(0, QIcon(":/text.png"));
        item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
        item->setText(1, object["Path"].toString());
        item->setData(1, Qt::UserRole, object["Path"].toString());
    }

    return item;
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:37,代码来源:FilterLibraryTreeWidget.cpp

示例6: on_moveItemDownButton_clicked

void TreeWidgetEditor::on_moveItemDownButton_clicked()
{
    QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
    if (!curItem)
        return;

    int idx, idxCount;
    if (curItem->parent()) {
        idx = curItem->parent()->indexOfChild(curItem);
        idxCount = curItem->parent()->childCount();
    } else {
        idx = ui.treeWidget->indexOfTopLevelItem(curItem);
        idxCount = ui.treeWidget->topLevelItemCount();
    }
    if (idx == idxCount - 1)
        return;

    QTreeWidgetItem *takenItem;
    ui.treeWidget->blockSignals(true);
    if (curItem->parent()) {
        QTreeWidgetItem *parentItem = curItem->parent();
        takenItem = parentItem->takeChild(idx);
        parentItem->insertChild(idx + 1, takenItem);
    } else {
        takenItem = ui.treeWidget->takeTopLevelItem(idx);
        ui.treeWidget->insertTopLevelItem(idx + 1, takenItem);
    }
    ui.treeWidget->blockSignals(false);

    ui.treeWidget->setCurrentItem(takenItem, ui.treeWidget->currentColumn());
    updateEditor();
}
开发者ID:maxxant,项目名称:qt,代码行数:32,代码来源:treewidgeteditor.cpp

示例7: on_downButton_clicked

void InstrumentWizard::on_downButton_clicked()
      {
      QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
      if (wi.isEmpty())
            return;
      QTreeWidgetItem* item = wi.front();
      if (item->type() == PART_LIST_ITEM) {
            bool isExpanded = partiturList->isItemExpanded(item);
            int idx = partiturList->indexOfTopLevelItem(item);
            int n = partiturList->topLevelItemCount();
            if (idx < (n-1)) {
                  partiturList->selectionModel()->clear();
                  QTreeWidgetItem* item = partiturList->takeTopLevelItem(idx);
                  partiturList->insertTopLevelItem(idx+1, item);
                  partiturList->setItemExpanded(item, isExpanded);
                  partiturList->setItemSelected(item, true);
                  }
            }
      else {
            QTreeWidgetItem* parent = item->parent();
            int idx = parent->indexOfChild(item);
            int n = parent->childCount();
            if (idx < (n-1)) {
                  partiturList->selectionModel()->clear();
                  QTreeWidgetItem* item = parent->takeChild(idx);
                  parent->insertChild(idx+1, item);
                  partiturList->setItemSelected(item, true);
                  }
            }
      }
开发者ID:Archer90,项目名称:MuseScore,代码行数:30,代码来源:newwizard.cpp

示例8: moveItemDown

void TabStopDialog::moveItemDown()
{
    QTreeWidgetItem *selected = m_widgetTree->selectedItem();
    if (!selected)
        return;
    // we assume there is flat list
    QTreeWidgetItem *root = m_widgetTree->invisibleRootItem();
    const int selectedIndex = root->indexOfChild(selected);
    if (selectedIndex >= (root->childCount() - 1))
        return; // no place to move
    root->takeChild(selectedIndex);
    root->insertChild(selectedIndex + 1, selected);
    updateButtons(selected);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:14,代码来源:tabstopdialog.cpp

示例9: moveItemUp

void TabStopDialog::moveItemUp()
{
    QTreeWidgetItem *selected = d->widgetTree->selectedItem();
    if (!selected)
        return;
    // we assume there is flat list
    QTreeWidgetItem *root = d->widgetTree->invisibleRootItem();
    const int selectedIndex = root->indexOfChild(selected);
    if (selectedIndex < 1)
        return; // no place to move
    root->takeChild(selectedIndex);
    root->insertChild(selectedIndex - 1, selected);
    updateButtons(selected);
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:14,代码来源:tabstopdialog.cpp

示例10: MoveCurrentItem

void GlobalSearchSettingsPage::MoveCurrentItem(int d) {
  QTreeWidgetItem* item = ui_->sources->currentItem();
  if (!item) return;

  QTreeWidgetItem* root = ui_->sources->invisibleRootItem();

  const int row = root->indexOfChild(item);
  const int new_row = qBound(0, row + d, root->childCount());

  if (row == new_row) return;

  root->removeChild(item);
  root->insertChild(new_row, item);

  ui_->sources->setCurrentItem(item);
}
开发者ID:Aceler,项目名称:Clementine,代码行数:16,代码来源:globalsearchsettingspage.cpp

示例11: move_to_sorted_position

void move_to_sorted_position(QTreeWidgetItem* item)
{
    assert(item);

    if (item->parent())
    {
        QTreeWidgetItem* parent = item->parent();
        parent->removeChild(item);
        parent->insertChild(find_sorted_position(parent, item->text(0)), item);
    }
    else if (item->treeWidget())
    {
        QTreeWidget* parent = item->treeWidget();
        parent->takeTopLevelItem(parent->indexOfTopLevelItem(item));
        parent->insertTopLevelItem(find_sorted_position(parent, item->text(0)), item);
    }
}
开发者ID:hipopotamo-hipotalamo,项目名称:appleseed,代码行数:17,代码来源:treewidget.cpp

示例12: swapItems

void TreeWidget::swapItems(QTreeWidgetItem* source, QTreeWidgetItem* target)
{
    QTreeWidgetItem* parent = source->parent();
    if (!parent)
        parent = invisibleRootItem();
    const bool se = source->isExpanded();
    const bool ss = source->isFirstColumnSpanned();
    const bool te = target->isExpanded();
    const bool ts = target->isFirstColumnSpanned();
    const int idx = parent->indexOfChild(target);
    parent->takeChild(parent->indexOfChild(source));
    parent->insertChild(idx, source);
    source->setExpanded(se);
    source->setFirstColumnSpanned(ss);
    target->setExpanded(te);
    target->setFirstColumnSpanned(ts);
}
开发者ID:jpnurmi,项目名称:communi-desktop,代码行数:17,代码来源:treewidget.cpp

示例13: move_Down

void Structure_Toolbar::move_Down(bool)
{
	int position = structure_Tree->tree->currentIndex().row();
	QTreeWidgetItem* parent = structure_Tree->tree->currentItem()->parent();

	// if nested
	if(parent)
	{
		QTreeWidgetItem* taken = parent->takeChild(position+1);
		parent->insertChild(position, taken);
	} else
	{
		QTreeWidgetItem* taken = structure_Tree->tree->takeTopLevelItem(position+1);
		structure_Tree->tree->insertTopLevelItem(position, taken);
	}

	refresh_Toolbar();
}
开发者ID:svech,项目名称:Multifitting,代码行数:18,代码来源:structure_toolbar.cpp

示例14: newFolder

void LibraryTreeWidget::newFolder()
{
	QTreeWidgetItem* root = invisibleRootItem();

	if (selectedItems().empty() == false)
		root = selectedItems().front();

	QTreeWidgetItem *item = createFolderItem("New Folder");

	root->setExpanded(true);
	if (root == invisibleRootItem())
		root->addChild(item);
	else
		root->insertChild(0, item);

	editItem(item, 0);

	checkModification();
}
开发者ID:lsouchet,项目名称:gideros,代码行数:19,代码来源:librarytreewidget.cpp

示例15: buildBoundaryList

void MainWindow::buildBoundaryList() {
  QTreeWidgetItem *item = ui.BoundaryTree->topLevelItem(0);
  item->child(0)->setText(1,sim.getBoundaryText(0));
  item->child(1)->setText(1,sim.getBoundaryText(1));
  item->child(2)->setText(1,sim.getBoundaryText(2));
  item->child(3)->setText(1,sim.getBoundaryText(3));
  item->child(4)->setText(1,sim.getBoundaryText(4));
  item->child(5)->setText(1,sim.getBoundaryText(5));

  QTreeWidgetItem *new_item;
  long int extent_a[2];
  long int extent_b[2];
  QString type;
  QString extents;
  double value;
  double turbulence;
  int n;
  for(int i=0; i<6; i++) {
    item = ui.BoundaryTree->topLevelItem(1)->child(i);

    qDeleteAll(item->takeChildren());

    sim.resetSpecialBoundary(i);
    while(sim.getNextSpecialBoundary(type, extent_a, extent_b, value, turbulence)) {
      new_item = new QTreeWidgetItem(QTreeWidgetItem::Type);
      
      extents = QString::number(extent_a[0]) + 
                "," + QString::number(extent_a[1]) +
                " to " + QString::number(extent_b[0]) +
                "," + QString::number(extent_b[1]);
      n = item->childCount();

      item->insertChild(n, new_item);
      new_item->setText(0, QString::number(n+1));
      new_item->setText(1, type);
      new_item->setText(2, extents);
      new_item->setText(3, QString::number(value));
      new_item->setText(4, QString::number(turbulence));
    }
  }  


}
开发者ID:Dylnn,项目名称:Civil-CFD,代码行数:43,代码来源:MainWindow_Boundaries.cpp


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