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


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

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


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

示例1: modelExcelRemoveFile

void OutputWindow::modelExcelRemoveFile(const QString &name)
{
    QTreeWidget* tree = ui->treeWidget;
    QTreeWidgetItem* root = tree->topLevelItem(0);
    QFileInfo info(name);
    QString xlpath = info.absolutePath().replace(modelFolder, tr(""));
    QString xlfile = info.fileName();

    bool removed = false;
    for(int j = 0; j<root->childCount(); ++j) {
        if(root->child(j)->text(0).compare(xlpath, Qt::CaseInsensitive) == 0) {
            QTreeWidgetItem* item = root->child(j);
            for(int k = 0; k< item->childCount(); ++k) {
                if( item->child(k)->text(0).compare(xlfile, Qt::CaseInsensitive) == 0) {
                    //Gotcha!
                    item->takeChild(k);
                    removed = true;
                    break;//for-k
                }
            }
            if(removed) {
                if( item->childCount() == 0) {
                    root->takeChild(j);
                }
                break;//for-j
            }
        } else if(root->child(j)->text(0).compare(xlfile, Qt::CaseInsensitive) == 0) {
            root->takeChild(j);
            break;//for-j
        }
    }

}
开发者ID:LMiceOrg,项目名称:Modelingtools,代码行数:33,代码来源:outputwindow.cpp

示例2: on_moveItemLeftButton_clicked

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

    QTreeWidgetItem *parentItem = curItem->parent();
    if (!parentItem)
        return;

    m_updating = true;

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

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

示例3: on_moveActionLeftButton_clicked

/** Removes an action */
void DlgCustomToolbars::on_moveActionLeftButton_clicked()
{
    QTreeWidgetItem* item = toolbarTreeWidget->currentItem();
    if (item && item->parent() && toolbarTreeWidget->isItemSelected(item)) {
        QTreeWidgetItem* parent = item->parent();
        int index = parent->indexOfChild(item);
        parent->takeChild(index);

        // In case a separator should be moved we have to count the separators
        // which come before this one.
        // This is needed so that we can distinguish in removeCustomCommand
        // which separator it is.
        QByteArray data = item->data(0, Qt::UserRole).toByteArray();
        if (data == "Separator") {
            int countSep = 1;
            for (int i=0; i<index-1; i++) {
                QByteArray d = parent->child(i)->data(0, Qt::UserRole).toByteArray();
                if (d == "Separator") {
                    countSep++;
                }
            }

            data += QByteArray::number(countSep);
        }
        removeCustomCommand(parent->text(0), data);
        delete item;
    }

    QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
    QString workbench = data.toString();
    exportCustomToolbars(workbench.toLatin1());
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:33,代码来源:DlgToolbarsImp.cpp

示例4: 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;

    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,代码行数:33,代码来源:treewidgeteditor.cpp

示例5: showTheoryNodes

void TestHelpSelectingDialog::showTheoryNodes()
{
    QTreeWidgetItem *root = new QTreeWidgetItem();

    for (int i = 0; i < theoryNodes.length(); i++)
    {
        KeyStorageNode currentNode = theoryNodes.at(i);

        QList<Key> keys = currentNode.getInnerKeys();

        for (int j = 0; j < keys.length(); j++)
        {
            Key currentKey = keys.at(j);
            addKey(root, currentKey, currentNode.getPluginName(), i, Qt::UserRole);
        }
    }

    ui->treeWidgetChangeTheme->clear();

    while (root->childCount() != 0)
    {
        ui->treeWidgetChangeTheme->addTopLevelItem(root->takeChild(0));
    }

    delete root;

    ui->treeWidgetChangeTheme->sortByColumn(0, Qt::AscendingOrder);
}
开发者ID:Art1991,项目名称:Exams_v2,代码行数:28,代码来源:testhelpselectingdialog.cpp

示例6: removeTreeItems

void BoincTree::removeTreeItems(InfoBoinc::Session::IdType id, QList<QTreeWidgetItem *> items)
{
	QTreeWidgetItem *sessionItem = m_sessionItems[id];
	m_tree->setUpdatesEnabled(false);
	foreach (QTreeWidgetItem *item, items) {
		sessionItem->takeChild(sessionItem->indexOfChild(item));
	}
开发者ID:mireq,项目名称:QBoincGui,代码行数:7,代码来源:BoincTree.cpp

示例7: onRemoveRequest

/*
  The user has triggered the action to remove a file from the project.
  Grab the file name and signal ProjectInfo to make the change.
*/
void FileBrowser::onRemoveRequest()
{
  QString filepath = currentItem()->text(FILENAME_COLUMN);
  QTreeWidgetItem *top = topLevelItem(0);
  delete top->takeChild(top->indexOfChild(currentItem()));
  emit removeFileRequest(filepath);
}
开发者ID:YTakami,项目名称:makecontroller,代码行数:11,代码来源:ProjectInfo.cpp

示例8: on_removeButton_clicked

void InstrumentWizard::on_removeButton_clicked()
      {
      QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
      if (wi.isEmpty())
            return;
      QTreeWidgetItem* item = wi.front();
      QTreeWidgetItem* parent = item->parent();

      if (parent) {
            if (((StaffListItem*)item)->op == ITEM_ADD) {
                  if (parent->childCount() == 1) {
                        partiturList->takeTopLevelItem(partiturList->indexOfTopLevelItem(parent));
                        delete parent;
                        }
                  else {
                        parent->takeChild(parent->indexOfChild(item));
                        delete item;
                        }
                  }
            else {
                  ((StaffListItem*)item)->op = ITEM_DELETE;
                  partiturList->setItemHidden(item, true);
                  }
            }
      else {
            if (((PartListItem*)item)->op == ITEM_ADD)
                  delete item;
            else {
                  ((PartListItem*)item)->op = ITEM_DELETE;
                  partiturList->setItemHidden(item, true);
                  }
            }
      partiturList->clearSelection();
      emit completeChanged(partiturList->topLevelItemCount() > 0);
      }
开发者ID:Archer90,项目名称:MuseScore,代码行数:35,代码来源:newwizard.cpp

示例9: 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

示例10: 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;

    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,代码行数:29,代码来源:treewidgeteditor.cpp

示例11: removePoint

void QgsMeasureDialog::removePoint()
{
  if ( !mMeasureArea )
  {
    QTreeWidgetItem* parent = mTable->topLevelItem( mTable->topLevelItemCount() - 1 );
    delete parent->takeChild( parent->childCount() - 1 );
  }
  updateMeasurements();
}
开发者ID:sourcepole,项目名称:kadas-albireo,代码行数:9,代码来源:qgsmeasuredialog.cpp

示例12: while

/* Delete unused channels from previous user */
void ChannelTreeWidget::RemoteChannelUpdater::prunePreviousUser()
{
  if (toplevelidx > 0) {
    QTreeWidgetItem *user = owner->topLevelItem(toplevelidx);
    while (user->childCount() > childidx + 1) {
      QTreeWidgetItem *channel = user->takeChild(user->childCount() - 1);
      delete channel;
    }
  }
}
开发者ID:tzhuan,项目名称:wahjam,代码行数:11,代码来源:ChannelTreeWidget.cpp

示例13: onRemove

/*! \brief Remove the selected entity node
*/
void EntitiesTreeWidget::onRemove()
{
    QTreeWidgetItem *item = currentItem();


    if(!item){
        return;
    }



    if(QMessageBox::question(this,"Removing","Are you sure to remove this item?") == QMessageBox::Yes){

        if(item->parent() == applicationNode){
            if(item->data(0,Qt::UserRole)  == yarp::manager::APPLICATION){
                yarp::manager::Application *app = (yarp::manager::Application*)item->data(0,Qt::UserRole + 1).toLongLong();
                if(app){
                    QString appName = item->text(0);

                    removeApplication(appName);
                }

            }
        }else
            if(item->parent() == resourcesNode){
                if(item->data(0,Qt::UserRole)  == yarp::manager::RESOURCE){
                    yarp::manager::Computer *res = (yarp::manager::Computer*)item->data(0,Qt::UserRole + 1).toLongLong();
                    if(res){
                        QString resName = item->text(0);

                        removeResource(resName);
                    }
                }
            }else
            if(item->parent() == modulesNode){
                if(item->data(0,Qt::UserRole)  == yarp::manager::MODULE){
                    yarp::manager::Module *mod = (yarp::manager::Module*)item->data(0,Qt::UserRole + 1).toLongLong();
                    if(mod){
                        QString modName = item->text(0);

                        removeModule(modName);
                    }
                }
            }

            while(item->childCount()>0){
                delete item->takeChild(0);
            }

            if(item->parent()){
                int index = item->parent()->indexOfChild(item);
                delete item->parent()->takeChild(index);
            }
    }
}
开发者ID:robotology-playground,项目名称:yarpmanager2,代码行数:57,代码来源:entitiestreewidget.cpp

示例14: prunePreviousUser

void ChannelTreeWidget::RemoteChannelUpdater::commit()
{
  prunePreviousUser();

  while (owner->topLevelItemCount() > toplevelidx + 1) {
    QTreeWidgetItem *user = owner->takeTopLevelItem(owner->topLevelItemCount() - 1);
    while (user->childCount() > 0) {
      QTreeWidgetItem *channel = user->takeChild(user->childCount() - 1);
      delete channel;
    }
    delete user;
  }
}
开发者ID:tzhuan,项目名称:wahjam,代码行数:13,代码来源:ChannelTreeWidget.cpp

示例15: tr

void 
QDjViewOutline::refresh()
{
  QDjVuDocument *doc = djview->getDocument();
  if (doc && !loaded && djview->pageNum()>0)
    {
      miniexp_t outline = doc->getDocumentOutline();
      if (outline == miniexp_dummy)
        return;
      loaded = true;
      if (outline)
        {
          if (!miniexp_consp(outline) ||
              miniexp_car(outline) != miniexp_symbol("bookmarks"))
            {
              QString msg = tr("Outline data is corrupted");
              qWarning("%s", (const char*)msg.toLocal8Bit());
            }
          tree->clear();
          QTreeWidgetItem *root = new QTreeWidgetItem();
          fillItems(root, miniexp_cdr(outline));
          while (root->childCount() > 0)
            tree->insertTopLevelItem(tree->topLevelItemCount(),
                                     root->takeChild(0) );
          if (tree->topLevelItemCount() == 1)
            tree->topLevelItem(0)->setExpanded(true);
          delete root;
        }
      else
        {
          tree->clear();
          QTreeWidgetItem *root = new QTreeWidgetItem(tree);
          root->setText(0, tr("Pages"));
          root->setFlags(Qt::ItemIsEnabled);
          root->setData(0, Qt::UserRole, -1);
          for (int pageno=0; pageno<djview->pageNum(); pageno++)
            {
              QTreeWidgetItem *item = new QTreeWidgetItem(root);
              QString name = djview->pageName(pageno);
              item->setText(0, tr("Page %1").arg(name));
              item->setData(0, Qt::UserRole, pageno);
              item->setData(0, Qt::UserRole+1, pageno);
              item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
              item->setToolTip(0, tr("Go: page %1.").arg(name));
              item->setWhatsThis(0, whatsThis());
            }
          tree->setItemExpanded(root, true);
        }
      pageChanged(djview->getDjVuWidget()->page());
    }
}
开发者ID:Distrotech,项目名称:djview4,代码行数:51,代码来源:qdjviewsidebar.cpp


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