本文整理汇总了C++中QTreeWidgetItem::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::addChild方法的具体用法?C++ QTreeWidgetItem::addChild怎么用?C++ QTreeWidgetItem::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTreeList
void SettingsEditorForm::updateTreeList(QString path, QStringList newDirs, QStringList newElements)
{
QStringList dirs = path.split("/");
dirs.removeFirst();
QTreeWidgetItem* iter = ui->treeWidget->topLevelItem(0);
for(QString dir : dirs)
{
for(int i=0; i<iter->childCount(); i++)
{
if(iter->child(i)->type() == TWT_DIR
&& iter->child(i)->text(0) == dir)
{
iter = iter->child(i);
}
}
}
for(QString dir : newDirs)
{
QTreeWidgetItem * newItem = new QTreeWidgetItem(TWT_DIR);
newItem->setText(0, dir);
iter->addChild( newItem );
}
for(QString element : newElements)
{
QTreeWidgetItem * newItem = new QTreeWidgetItem(TWT_RES);
newItem->setText(0, element);
iter->addChild( newItem );
}
ui->treeWidget->expandAll();
}
示例2: addProcessorNetwork
void PropertySelectionTreeWidget::addProcessorNetwork(ProcessorNetwork* processorNetwork, std::string workspaceFileName) {
std::vector<Processor*> processors = processorNetwork->getProcessors();
QTreeWidgetItem* worksapceItem = new QTreeWidgetItem(QStringList(QString::fromStdString(workspaceFileName)));
if (processors.size())
propertySelectionTree_->addTopLevelItem(worksapceItem);
else {
LogWarn("Empty workpace with no processors" << workspaceFileName);
return;
}
for (auto& processor : processors) {
std::vector<Property*> properties = processor->getProperties();
std::string processorId = processor->getIdentifier();
QTreeWidgetItem* processorItem = new QTreeWidgetItem(QStringList(QString::fromStdString(processorId)));
worksapceItem->addChild(processorItem);
for (auto& propertie : properties) {
std::string id = propertie->getIdentifier();
QTreeWidgetItem* newItem = new QTreeWidgetItem(QStringList(QString::fromStdString(id)));
processorItem->addChild(newItem);
newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable);
newItem->setCheckState(0, Qt::Unchecked);
}
propertySelectionTree_->addTopLevelItem(processorItem);
processorItem->sortChildren(0, Qt::AscendingOrder);
}
propertySelectionTree_->expandAll();
}
示例3: reloadAll
void CirclesDialog::reloadAll()
{
requestGroupMeta();
/* grab all ids */
std::list<std::string> friend_pgpIds;
std::list<std::string> all_pgpIds;
std::list<std::string>::iterator it;
std::set<std::string> friend_set;
rsPeers->getGPGAcceptedList(friend_pgpIds);
rsPeers->getGPGAllList(all_pgpIds);
/* clear tree */
ui.treeWidget_friends->clear();
/* add the top level item */
QTreeWidgetItem *friendsItem = new QTreeWidgetItem();
friendsItem->setText(0, tr("Friends"));
ui.treeWidget_friends->addTopLevelItem(friendsItem);
QTreeWidgetItem *fofItem = new QTreeWidgetItem();
fofItem->setText(0, tr("Friends Of Friends"));
ui.treeWidget_friends->addTopLevelItem(fofItem);
for(it = friend_pgpIds.begin(); it != friend_pgpIds.end(); it++)
{
RsPeerDetails details;
if (rsPeers->getGPGDetails(*it, details))
{
friend_set.insert(*it);
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(CIRCLEGROUP_FRIEND_COL_NAME, QString::fromUtf8(details.name.c_str()));
item->setText(CIRCLEGROUP_FRIEND_COL_ID, QString::fromStdString(*it));
friendsItem->addChild(item);
}
}
for(it = all_pgpIds.begin(); it != all_pgpIds.end(); it++)
{
if (friend_set.end() != friend_set.find(*it))
{
// already added as a friend.
continue;
}
RsPeerDetails details;
if (rsPeers->getGPGDetails(*it, details))
{
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(CIRCLEGROUP_FRIEND_COL_NAME, QString::fromUtf8(details.name.c_str()));
item->setText(CIRCLEGROUP_FRIEND_COL_ID, QString::fromStdString(*it));
fofItem->addChild(item);
}
}
}
示例4: makeEmptyTree
void MainWindow::makeEmptyTree(){
ui->treeWidget->clear();
//Set tree widget table headers
ui->treeWidget->setColumnCount(4);
ui->treeWidget->headerItem()->setText(0,"");
ui->treeWidget->headerItem()->setText(1,"Academic Year");
ui->treeWidget->headerItem()->setText(2,"Hours");
ui->treeWidget->headerItem()->setText(3,"Students");
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(1,"0");
item->setText(2,"0");
item->setText(3,"0");
//build headers
QTreeWidgetItem *pme = root2("PME", "0", "0");
pme->addChild(item);
QTreeWidgetItem *ume = root2("UME", "0","0");
QTreeWidgetItem *item2 = new QTreeWidgetItem();
item->setText(1,"0");
item->setText(2,"0");
item->setText(3,"0");
ume->addChild(item2);
QTreeWidgetItem *cme = root2("CME", "0", "0");
QTreeWidgetItem *item3 = new QTreeWidgetItem();
item->setText(1,"0");
item->setText(2,"0");
item->setText(3,"0");
cme->addChild(item3);
QTreeWidgetItem *other = root2("Other", "0", "0");
QTreeWidgetItem *item4 = new QTreeWidgetItem();
item->setText(1,"0");
item->setText(2,"0");
item->setText(3,"0");
other->addChild(item4);
//hide tree
pme->setHidden(true);
cme->setHidden(true);
ume->setHidden(true);
other->setHidden(true);
//generate date ranges
for (int x = 1975; x <= 2015; x ++)
{
ui->comboBox_start->addItem(QString::number(x));
ui->comboBox_end->addItem(QString::number(x));
}
// set default date range
ui->comboBox_start->setCurrentIndex(0);
ui->comboBox_end->setCurrentIndex(ui->comboBox_end->count()-1);
}
示例5: myDir
QTreeWidgetItem * Widget::scanDirectory(QString path)
{
QTreeWidgetItem * root;
QDir myDir(path);
QTreeWidgetItem * tmp;
root = new QTreeWidgetItem(0);
root->setText(0, myDir.dirName());
QString dir = qApp->applicationDirPath();
QDirIterator * scanDir= new QDirIterator(path, QDir::AllEntries|QDir::NoDotAndDotDot);
QString nxt;
while(scanDir->hasNext())
{
nxt = scanDir->next();
qDebug(scanDir->filePath().toAscii());
if(scanDir->fileInfo().isDir())
{
root->addChild(scanDirectory(scanDir->filePath()));
totalDownloads++;
}
else
{
tmp = new QTreeWidgetItem(0);
tmp->setText(0, scanDir->fileName());
root->addChild(tmp);
totalDownloads++;
}
}
/*if(!nxt.isNull())
{
qDebug(scanDir->filePath().toAscii());
if(scanDir->fileInfo().isDir())
{
root->addChild(scanDirectory(scanDir->filePath()));
}
else
{
tmp = new QTreeWidgetItem(0);
tmp->setText(0, scanDir->fileName());
root->addChild(tmp);
}
}*/
return root;
}
示例6: BuildTree
void mtsQtCommandSelector::BuildTree(mtsManagerGlobal* globalComponentManager) {
clear();
QTreeWidgetItem* processItem;
QTreeWidgetItem* componentItem;
QTreeWidgetItem* interfaceItem;
QTreeWidgetItem* commandItem;
QStringList strings;
std::vector<std::string> processNames;
std::vector<std::string> componentNames;
std::vector<std::string> interfaceNames;
std::vector<std::string> commandNames;
globalComponentManager->GetNamesOfProcesses(processNames);
// Processes
for(std::vector<std::string>::const_iterator processName = processNames.begin(); processName < processNames.end(); ++processName) {
strings << processName->c_str() << "Process";
processItem = new QTreeWidgetItem(strings);
addTopLevelItem(processItem);
strings.clear();
// Components
componentNames.clear();
globalComponentManager->GetNamesOfComponents(*processName, componentNames);
for(std::vector<std::string>::const_iterator componentName = componentNames.begin(); componentName < componentNames.end(); ++componentName) {
strings << componentName->c_str() << "Component";
componentItem = new QTreeWidgetItem(strings);
processItem->addChild(componentItem);
strings.clear();
// Interfaces
interfaceNames.clear();
globalComponentManager->GetNamesOfInterfacesProvidedOrOutput(*processName, *componentName, interfaceNames);
for(std::vector<std::string>::const_iterator interfaceName = interfaceNames.begin(); interfaceName < interfaceNames.end(); ++interfaceName) {
strings << interfaceName->c_str() << "Interface";
interfaceItem = new QTreeWidgetItem(strings);
componentItem->addChild(interfaceItem);
strings.clear();
// Commands
commandNames.clear();
globalComponentManager->GetNamesOfCommands(*processName, *componentName, *interfaceName, commandNames);
for(std::vector<std::string>::const_iterator commandName = commandNames.begin(); commandName < commandNames.end(); ++commandName) {
strings << commandName->c_str() << "Command";
commandItem = new QTreeWidgetItem(strings);
interfaceItem->addChild(commandItem);
strings.clear();
}
}
}
}
}
示例7: setAreaWidget
void QJDMainWindow::setAreaWidget(QString areaString, QString areaPath, QStringList lineStringList,
QStringList linePathList, QVector<QStringList> flowStringList,
QVector<QStringList> flowPathList,QVector<QVector<QStringList> > dataStringList,
QVector<QVector<QStringList> > dataPathList)
{
// qDebug()<<"setAreaWidget::"<<flowStringList<<flowPathList;
QTreeWidgetItem *areaItem = new QTreeWidgetItem;
areaItem->setText(0,areaString);
areaItem->setToolTip(0,areaPath);
areaItem->setIcon(0,QIcon(":/src/images/area.png"));
for(int j=0; j<lineStringList.count(); j++)
{
QTreeWidgetItem *lineItem = new QTreeWidgetItem;
lineItem->setText(0,lineStringList.at(j));
lineItem->setToolTip(0,linePathList.at(j));
lineItem->setIcon(0,QIcon(":/src/images/line.png"));
for(int k=0; k<flowStringList[j].size(); k++)
{
QTreeWidgetItem *flowItem = new QTreeWidgetItem;
flowItem->setText(0,flowStringList[j].at(k));
flowItem->setToolTip(0,flowPathList[j].at(k));
if(flowStringList[j].at(k)=="Data")
{
flowItem->setIcon(0,QIcon(":/src/images/data.png"));
}
else
{
flowItem->setIcon(0,QIcon(":/src/images/flow.png"));
}
lineItem->addChild(flowItem);
// Scan/Pick
for(int l=0; l<dataStringList[j][k].size(); l++)
{
QTreeWidgetItem *dataItem = new QTreeWidgetItem;
dataItem->setText(0,dataStringList[j][k].at(l));
dataItem->setToolTip(0,dataPathList[j][k].at(l));
// dataItem->setIcon(0,QIcon(":/src/images/flow.png"));
flowItem->addChild(dataItem);
// qDebug()<<lineStringList.count()<<j<<flowStringList[j].size()<<k<<dataStringList[k].size()<<l;
}
}
areaItem->addChild(lineItem);
}
areaWidget->addTopLevelItem(areaItem);
}
示例8: ChunksToDisplay
void MainWindow::ChunksToDisplay(CIffHeader *pHead, QTreeWidgetItem *pTopItem)
{
// root-level chunk-nodes
CIffChunk *pChunk = pHead->m_pFirst;
while (pChunk != nullptr)
{
QTreeWidgetItem *pChunkItem = new QTreeWidgetItem(pTopItem);
pChunkItem->setText(0, IdToString(pChunk->m_iChunkID));
pChunkItem->setText(1, QString::number(pChunk->m_iOffset));
pChunkItem->setText(2, QString::number(pChunk->m_iChunkSize));
pTopItem->addChild(pChunkItem);
CIffSubChunk *pSubChunk = pChunk->m_pSubChunk;
while (pSubChunk != nullptr)
{
QTreeWidgetItem *pSubItem = new QTreeWidgetItem(pChunkItem);
pSubItem->setText(0, IdToString(pSubChunk->m_iChunkID));
pSubItem->setText(1, QString::number(pSubChunk->m_iOffset));
pSubItem->setText(2, QString::number(pSubChunk->m_iSize));
pChunkItem->addChild(pSubItem);
pSubChunk = pSubChunk->m_pNextSub;
}
pChunk = pChunk->m_pNext;
}
}
示例9: loadFileBrowser
/*
Update the file browser to show files in the project.
Read these from the project's project file.
*/
void ProjectInfo::loadFileBrowser(QDir *projectDir, QDomDocument *projectFile)
{
// setup the file browser
fileBrowser->clear(); // get rid of anything previously in there
QDomNodeList allFiles = projectFile->elementsByTagName("files").at(0).childNodes();
QTreeWidgetItem *top = new QTreeWidgetItem(QStringList() << projectDir->dirName());
top->setIcon(0, QApplication::style()->standardIcon(QStyle::SP_DirIcon));
fileBrowser->addTopLevelItem(top);
// only deals with files in the top level directory at the moment
QFileIconProvider ip;
for(int i = 0; i < allFiles.count(); i++)
{
QFileInfo fi(projectDir->filePath(allFiles.at(i).toElement().text()));
if(!fi.fileName().isEmpty())
{
if(projectDir->exists(fi.fileName()))
{
QString buildtype = allFiles.at(i).toElement().attribute("type");
QTreeWidgetItem *child = new QTreeWidgetItem(QStringList() << fi.fileName() << buildtype);
child->setData(FILENAME_COLUMN, FULLPATH_ROLE, fi.filePath());
child->setToolTip(FILENAME_COLUMN, fi.filePath());
child->setIcon(FILENAME_COLUMN, ip.icon(fi));
top->addChild(child);
}
}
}
top->setExpanded(true);
}
示例10: loadProjects
void EditTache::loadProjects()
{
ProjetManager& manager = ProjetManager::Instance();
unsigned int nbProj = manager.getNb();
QTreeWidget * tree = ui->treeWidget;
for(int i = 0; i < nbProj; i++)
{
QTreeWidgetItem * projet = new QTreeWidgetItem();
Projet& proj = manager.getProjet(i);
unsigned int nbTaches = proj.getNb();
projet->setText(0, QString::fromStdString(proj.getTitre()));
for(int i=0; i < nbTaches; i++)
{
QTreeWidgetItem * tache = new QTreeWidgetItem();
Tache& t = proj.getTache(i);
tache->setText(0, QString::fromStdString(t.getTitre()));
projet->addChild(tache);
}
tree->addTopLevelItem(projet);
}
}
示例11: loadMacro
void InsertFxPopup::loadMacro()
{
TFilePath fp = m_presetFolder + TFilePath("macroFx");
try {
if (TFileStatus(fp).isDirectory()) {
TFilePathSet macros = TSystem::readDirectory(fp);
if (macros.empty())
return;
QTreeWidgetItem *macroFolder = new QTreeWidgetItem((QTreeWidget *)0, QStringList(tr("Macro")));
macroFolder->setData(0, Qt::UserRole, QVariant(toQString(fp)));
macroFolder->setIcon(0, m_folderIcon);
m_fxTree->addTopLevelItem(macroFolder);
for (TFilePathSet::iterator it = macros.begin(); it != macros.end(); ++it) {
TFilePath macroPath = *it;
QString name(macroPath.getName().c_str());
QTreeWidgetItem *macroItem = new QTreeWidgetItem((QTreeWidget *)0, QStringList(name));
macroItem->setData(0, Qt::UserRole, QVariant(toQString(macroPath)));
macroItem->setIcon(0, m_fxIcon);
macroFolder->addChild(macroItem);
}
}
} catch (...) {
}
}
示例12: addState
bool BookmarkGui::addState( QString new_state )
{
Bookmark bk ;
QueryResult favorite ;
bk.getFavoriteFullData( favorite , this->current_favorite );
QList<QTreeWidgetItem *> list_state =
ui->treeStates->findItems ( new_state , Qt::MatchExactly ) ;
if ( list_state.isEmpty() || list_state.size() > 1 ) return false ;
QTreeWidgetItem *state = list_state.first() ;
if ( state->type() != BookmarkGui::item_state ) return false ;
QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidgetItem*)0 , BookmarkGui::item_article ) ;
this->setArticleItemDecorations( item , this->current_favorite , this->current_favorite_id ) ;
state->addChild( item ) ;
state->setExpanded( true ) ;
ui->treeStates->setCurrentItem( item );
return true ;
}
示例13: viewName
void
PlanSimSubpanel::onSimulationFinished()
{
bool oldBlockTree = right->ui->treeSimViews->blockSignals(true);
right->ui->treeSimViews->clear();
onTimeout();
timer.stop();
if (sim_process and not sim_process->error_simu.isEmpty()) {
mLog->logExt(sim_process->error_simu, true);
} else if (sim_process and sim_process->output_map) {
const vle::value::Map& simu = *sim_process->output_map;
QList<QTreeWidgetItem*> views_items;
vle::value::Map::const_iterator itb = simu.begin();
vle::value::Map::const_iterator ite = simu.end();
for (; itb != ite; itb++) {
QString viewName(itb->first.c_str());
QStringList viewType = mvpz->getViewTypeFromDoc(viewName);
if (viewType.contains("finish")) {
QTreeWidgetItem* vItem = new QTreeWidgetItem();
vItem->setText(
0, QString("%1 (%2)").arg(viewName).arg("finish"));
vItem->setData(0, Qt::UserRole + 0, "view");
vItem->setData(0, Qt::UserRole + 1, viewName);
const vle::value::Matrix& res = itb->second->toMatrix();
for (unsigned int i = 0; i < res.columns(); i++) {
if (res.get(i, 0) and res.get(i, 0)->isString()) {
QString portName = res.getString(i, 0).c_str();
if (portName.contains("AchievedPlan")) {
QTreeWidgetItem* pItem = new QTreeWidgetItem();
pItem->setText(0, portName);
pItem->setFlags(vItem->flags() |
Qt::ItemIsUserCheckable);
pItem->setCheckState(0, Qt::Unchecked);
pItem->setData(0, Qt::UserRole + 0, "port");
pItem->setData(0, Qt::UserRole + 1, viewName);
pItem->setData(0, Qt::UserRole + 2, portName);
vItem->addChild(pItem);
}
}
}
views_items.append(vItem);
}
}
right->ui->treeSimViews->addTopLevelItems(views_items);
}
updateCustomPlot();
right->ui->treeSimViews->blockSignals(oldBlockTree);
thread->quit();
thread->wait();
delete thread;
thread = 0;
left->ui->runButton->setEnabled(true);
}
示例14: 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();
}
示例15: tagList
void Settings::FaceManagementPage::loadDatabase()
{
m_databaseEntries->clear();
m_databaseEntries->setSortingEnabled(false);
m_recognizer = FaceManagement::Recognizer::instance();
QMap<QString, QStringList> parsedIdentities = m_recognizer->allParsedIdentities();
QMapIterator<QString, QStringList> tagList(parsedIdentities);
while (tagList.hasNext()) {
tagList.next();
QTreeWidgetItem* category = new QTreeWidgetItem;
category->setText(0, tagList.key());
category->setFlags(Qt::ItemIsEnabled);
for (int i = 0; i < tagList.value().size(); ++i) {
QTreeWidgetItem* tag = new QTreeWidgetItem;
tag->setText(0, tagList.value().at(i));
tag->setText(1, QString::number(m_recognizer->getHistogramCount(tagList.key(),
tagList.value().at(i))));
tag->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
category->addChild(tag);
}
m_databaseEntries->addTopLevelItem(category);
category->setExpanded(true);
}
m_databaseEntries->setEnabled(true);
m_databaseEntries->setSortingEnabled(true);
m_databaseEntries->sortItems(0, Qt::AscendingOrder);
}