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


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

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


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

示例1: initList

void ColorDialog::initList()
{
  QTreeWidgetItem *rootItem;
  QList<QTreeWidgetItem *> elist;
  
  /* initialize color list */
  rootItem = ui_->listColors->invisibleRootItem();
  
  elist = rootItem->takeChildren();
  foreach (QTreeWidgetItem *i, elist)
      delete i;
  
  colorMap_.clear();
  
  for (int i = 0; i < ldraw::color::color_chart_count; ++i) {
    const ldraw::color_entity *ce = &ldraw::color::color_chart[i];
    
    newItem(rootItem, ce);
    colorMap_[ce->id] = i;
  }
  
  /* initialize favorites list */
  rootItem = ui_->listFavorites->invisibleRootItem();
  
  elist = rootItem->takeChildren();
  foreach (QTreeWidgetItem *i, elist)
      delete i;
  
  foreach (const ldraw::color &c, manager_->colorList())
      newItem(rootItem, c.get_entity());
  
  resetFavoritesMap();
}
开发者ID:bangkr,项目名称:Konstruktor,代码行数:33,代码来源:colordialog.cpp

示例2: modelNameChanged

void OutputWindow::modelNameChanged(const QString &title)
{
    QTreeWidget* tree;
    QTreeWidgetItem* item;

    modelFolder = title;

    tree = ui->treeWidget;

    item = tree->topLevelItem(0);
    item->takeChildren();
    item->setText(0, title);

    tree = ui->treeDataStruct;
    item = tree->topLevelItem(0);
    item->takeChildren();
    item->setText(0, title);

    tree = ui->treeModelDsc;
    item = tree->topLevelItem(0);
    item->takeChildren();
    item->setText(0, title);

    tree = ui->treeProject;
    item = tree->topLevelItem(0);
    item->takeChildren();
    item->setText(0, title);


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

示例3: OnSocItemDelete

void RegEdit::OnSocItemDelete()
{
    QTreeWidgetItem *current = m_soc_tree->currentItem();
    if(current == 0)
        return;
    QMessageBox msgbox(QMessageBox::Question, "Delete item ?",
        "Are you sure you want to delete this item ?",
        QMessageBox::Yes | QMessageBox::No, this);
    msgbox.setDefaultButton(QMessageBox::No);
    int ret = msgbox.exec();
    if(ret != QMessageBox::Yes)
        return;
    if(current->type() == SocTreeSocType)
    {
        SocTreeItem *item = dynamic_cast< SocTreeItem * >(current);
        item->GetRef().GetSoc().dev.clear();
        item->takeChildren();
        FillSocTreeItem(item);
        m_soc_tree->expandItem(item);
    }
    else if(current->type() == SocTreeDevType)
    {
        DevTreeItem *item = dynamic_cast< DevTreeItem * >(current);
        my_remove_at(item->GetRef().GetSoc().dev, item->GetRef().GetDevIndex());
        QTreeWidgetItem *parent = item->parent();
        parent->takeChildren();
        FillSocTreeItem(parent);
        m_soc_tree->expandItem(parent);
    }
    else if(current->type() == SocTreeRegType)
    {
        RegTreeItem *item = dynamic_cast< RegTreeItem * >(current);
        my_remove_at(item->GetRef().GetDev().reg, item->GetRef().GetRegIndex());
        QTreeWidgetItem *parent = item->parent();
        parent->takeChildren();
        FillDevTreeItem(parent);
        m_soc_tree->expandItem(parent);
    }
    else if(current->type() == SocTreeFieldType)
    {
        FieldTreeItem *item = dynamic_cast< FieldTreeItem * >(current);
        my_remove_at(item->GetRef().GetReg().field, item->GetRef().GetFieldIndex());
        QTreeWidgetItem *parent = item->parent();
        parent->takeChildren();
        FillRegTreeItem(parent);
        m_soc_tree->expandItem(parent);
    }
}
开发者ID:Cortexelus,项目名称:rockbox,代码行数:48,代码来源:regedit.cpp

示例4:

dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_take_children (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ());
      if (item) {

         QList<QTreeWidgetItem *> items = item->takeChildren ();
         const int Length = items.count ();
         V8Array array = v8::Array::New (Length);
         for (int ix = 0; ix < Length; ++ix) {

            V8Value value = self->create_v8_qtreewidgetitem (items.at (ix));
            array->Set (v8::Integer::New (ix), value);
         }
         result = array;
      }
   }

   return scope.Close (result);
}
开发者ID:bstewart33,项目名称:js,代码行数:26,代码来源:dmzJsModuleUiV8QtBasicTreeWidget.cpp

示例5: DiskTreeUpdated

void VSCDeviceList::DiskTreeUpdated()
{
	/* Delete all the disk */
	QTreeWidgetItem *qtreewidgetitem = ui.treeWidget->topLevelItem(VSC_DEVICE_INDEX_DSIK);

	qDeleteAll(qtreewidgetitem->takeChildren());

	VDBDiskStatus pStatus;
	gFactory->GetDiskStatus(pStatus);


	VDBDiskStatus::iterator it = pStatus.begin();

	for(; it!=pStatus.end(); ++it)
	{
		astring strName = (*it).first;
		VdbDiskStatus diskStatus = (*it).second;
		s8 DiskTitle[1024];
		memset(DiskTitle, 0, sizeof(DiskTitle));
		sprintf(DiskTitle, "  %lld%%",   
				((diskStatus.totalSize  - diskStatus.freeSize)* 100)/diskStatus.totalSize);
		strName = diskStatus.path + DiskTitle;
		AddDisk(strName);
	}

	ui.treeWidget->topLevelItem(VSC_DEVICE_INDEX_DSIK)->setExpanded(true);

	
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:29,代码来源:vscdevicelist.cpp

示例6:

QList<QTreeWidgetItem *> QTreeWidgetItemProto::takeChildren()
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    return item->takeChildren();
  return QList<QTreeWidgetItem*>();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: VmsTreeUpdated

void VSCDeviceList::VmsTreeUpdated()
{
	/* Delete all the site */
	{
		QTreeWidgetItem *qtreewidgetitem = ui.treeWidget->topLevelItem(VSC_DEVICE_INDEX_SITE);

		qDeleteAll(qtreewidgetitem->takeChildren());
	}

	VSCVmsData pData;
	gFactory->GetVms(pData);
	for (s32 i = 1; i < CONF_VMS_NUM_MAX; i ++)
	{
	    	if (pData.data.conf.vms[i].Used == 1)
	    	{
		        switch (pData.data.conf.vms[i].nType)
		        {
		            case VSC_VMS_SITE:
		            {
		                AddSite(pData.data.conf.vms[i]);
		                break;
		            }
		            default:
		            {

		                break;
		            }
		        }
	    	}else
	    	{
	    		continue;
	    	}
	}	
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:34,代码来源:vscdevicelist.cpp

示例8: modelModelCodeFiles

void OutputWindow::modelModelCodeFiles(const QStringList &sl)
{
    QTreeWidget * tree = ui->treeProject;
    QTreeWidgetItem* root = tree->topLevelItem(0);
    //Remove and return children list
    root->takeChildren();

    for(int i=0; i<sl.size(); ++i) {
        //        QString flabspath = sl.at(i);
        //        QString xlpath = flabspath.left(flabspath.lastIndexOf("/")).replace(modelFolder, tr(""));
        //        QString xlfile = flabspath.right(flabspath.length() -1 - flabspath.lastIndexOf("/") );
        QFileInfo info(sl.at(i));
        QString xlpath = info.absolutePath().replace(modelFolder, tr(""));
        QString xlfile = info.fileName();
        QString flabspath = info.absoluteFilePath();
        if(xlpath.compare("")!=0) {
            bool inserted = false;
            for(int j = 0; j<root->childCount(); ++j) {
                if(root->child(j)->text(0).compare(xlpath, Qt::CaseInsensitive) == 0) {
                    QTreeWidgetItem* item = new QTreeWidgetItem(
                                root->child(j),
                                QStringList(xlfile));
                    item->setIcon(0, GetIcon(xlfile) );
                    item->setData(0, Qt::UserRole, flabspath);
                    //                    item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon) );
                    inserted= true;
                    break;//for-j
                }
            }
            if(!inserted) {
                QTreeWidgetItem* path = new QTreeWidgetItem(
                            root,
                            QStringList(xlpath) );
                path->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
                //path->setIcon(0, QIcon(px.copy(4*px_width,4*px_height,  px_width,px_height)));
                QTreeWidgetItem* item = new QTreeWidgetItem(
                            path,
                            QStringList(xlfile));
                //                item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon) );
                item->setIcon(0, GetIcon(xlfile) );
                item->setData(0, Qt::UserRole, flabspath );
                //                root->addChild(path);
            }
        } else { //path is empty


            QTreeWidgetItem* item = new QTreeWidgetItem(
                        root,
                        QStringList(xlfile));
            item->setIcon(0, GetIcon(xlfile) );
            item->setData(0, Qt::UserRole, flabspath );
        }
    }
    tree->expandAll();
}
开发者ID:LMiceOrg,项目名称:Modelingtools,代码行数:55,代码来源:outputwindow.cpp

示例9: removeAllChildren

void TreeWidgetController::removeAllChildren(QTreeWidgetItem *parent)
{
    queue<QTreeWidgetItem *> q;
    for (q.push(parent); !q.empty(); q.pop()) {
        QTreeWidgetItem *item = q.front();
        foreach (QTreeWidgetItem *child, item->takeChildren())
            q.push(child);
        if (item != parent)
            delete item;
    }
}
开发者ID:Spencerx,项目名称:openBliSSART,代码行数:11,代码来源:TreeWidgetController.cpp

示例10: removeItem

 void DTTreeWidget::removeItem(const QString name)
 {
     QList<QTreeWidgetItem *> list = mCallTree.findItems(name, Qt::MatchContains | Qt::MatchRecursive);
     if (!list.empty())
     {         
         QTreeWidgetItem *item = list.at(0);
         QList<QTreeWidgetItem *> childs = item->takeChildren();
         foreach(QTreeWidgetItem *child, childs)
         {             
             mWidgetMap.remove(child->text(0));
             delete child;
         }
开发者ID:DentalTask,项目名称:main,代码行数:12,代码来源:DTTreeWidget.cpp

示例11: modelExcelListChanged

void OutputWindow::modelExcelListChanged(const QStringList &sl)
{
    QTreeWidget* tree = ui->treeWidget;
    QTreeWidgetItem* root = tree->topLevelItem(0);

    //Remove and return children list
    root->takeChildren();

    for(int i=0; i<sl.size(); ++i) {
        modelExcelAddFile(sl.at(i));
    }
    tree->expandAll();
}
开发者ID:LMiceOrg,项目名称:Modelingtools,代码行数:13,代码来源:outputwindow.cpp

示例12: sort

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

	if (selectedItems().empty() == false)
		root = selectedItems()[0];

	QList<QTreeWidgetItem*> children = root->takeChildren();

	std::sort(children.begin(), children.end(), LessQTreeWidgetItem());

	root->addChildren(children);
}
开发者ID:lsouchet,项目名称:gideros,代码行数:13,代码来源:librarytreewidget.cpp

示例13: removeNetwork

/*
When this method is called, the socket has already
removed the network from its tree.  Trying to access
it will result in a segmentation fault.  This is why
we have to set the current item to NULL to prevent
the session tree from autoselecting the next item
which doesn't exist.
*/
void IrcMainWindow::removeNetwork(const QString& network)
{
    ircSessionTreeView->setCurrentItem(NULL);
    ircTextView->setDocument(NULL);
    ircTextView->clear();
    ircUserListView->clear();

    QTreeWidgetItem *item = ircSessionTreeView->findItems(network,
				Qt::MatchExactly).at(0);
    item->takeChildren();
    for(int i=0; i<ircSessionTreeView->topLevelItemCount(); i++)
    {
	if(ircSessionTreeView->topLevelItem(i)->text(0) == network)
	    ircSessionTreeView->takeTopLevelItem(i);
    }
}
开发者ID:NickManley,项目名称:Qirc,代码行数:24,代码来源:IrcMainWindow.cpp

示例14: on_actionOpen_Nand_triggered

//file->open
void NandWindow::on_actionOpen_Nand_triggered()
{
    QString path = QFileDialog::getOpenFileName( this, tr( "Select a Nand to open" ) );
    if( path.isEmpty() )
        return;

    blocks.clear();
    if( !nThread.SetPath( path ) )
    {
        qDebug() << " error in nandBin.SetPath";
        ui->statusBar->showMessage( "Error setting path to " + path );
        return;
    }
    ui->statusBar->showMessage( "Loading " + path );
    QIcon groupIcon;
    QIcon keyIcon;
    groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirClosedIcon ), QIcon::Normal, QIcon::Off );
    groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirOpenIcon ), QIcon::Normal, QIcon::On );
    keyIcon.addPixmap( style()->standardPixmap( QStyle::SP_FileIcon ) );

    if( !nThread.InitNand( groupIcon, keyIcon ) )
    {
        qDebug() << " error in nandBin.InitNand()";
        ui->statusBar->showMessage( "Error reading " + path );
        return;
    }

    ui->treeWidget->clear();
    GetBlocksfromNand();
    DrawBlockMap();

    //get an item holding a tree with all the items of the nand
    //QTreeWidgetItem* tree = nandBin.GetTree();
    QTreeWidgetItem* tree = nThread.GetTree();

    //take the actual contents of the nand from the made up root and add them to the gui widget
    ui->treeWidget->addTopLevelItems( tree->takeChildren() );

    //delete the made up root item
    delete tree;

    //expand the root item
    if( ui->treeWidget->topLevelItemCount() )
        ui->treeWidget->topLevelItem( 0 )->setExpanded( true );

    ui->statusBar->showMessage( "Loaded " + path, 5000 );
}
开发者ID:Swyter,项目名称:wiiqt,代码行数:48,代码来源:nandwindow.cpp

示例15: modelDataStructFiles

void OutputWindow::modelDataStructFiles(const QStringList &sl)
{
    QTreeWidget * tree = ui->treeDataStruct;
    QTreeWidgetItem* root = tree->topLevelItem(0);
    //Remove and return children list
    root->takeChildren();

    for(int i=0; i<sl.size(); ++i) {
        QFileInfo info(sl.at(i));
        QString xmlfile = info.fileName();
        QTreeWidgetItem* item = new QTreeWidgetItem(root, QStringList( xmlfile ));
        //        item->setIcon(0, style()->standardIcon(QStyle::SP_DriveNetIcon));
        item->setIcon(0, *xmlIcon);
        item->setData(0, Qt::UserRole, info.absoluteFilePath() );
    }
    tree->expandAll();

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


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