本文整理汇总了C++中QTreeWidget类的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidget类的具体用法?C++ QTreeWidget怎么用?C++ QTreeWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTreeWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
//! [0]
QFontDatabase database;
QTreeWidget fontTree;
fontTree.setColumnCount(2);
fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
foreach (const QString &family, database.families()) {
QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
familyItem->setText(0, family);
foreach (const QString &style, database.styles(family)) {
QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
styleItem->setText(0, style);
QString sizes;
foreach (int points, database.smoothSizes(family, style))
sizes += QString::number(points) + " ";
styleItem->setText(1, sizes.trimmed());
}
//! [0] //! [1]
}
//! [1]
fontTree.resizeColumnToContents(0);
fontTree.show();
return app.exec();
}
示例2: QTreeWidgetItem
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);
}
}
示例3: Q_UNUSED
void TREE_SECIM_KERNEL::INIT_KERNEL ( QObject * parent,ADAK_SQL * database )
{
Q_UNUSED ( parent );
m_secilen_check_box_column = -1;
if (m_is_multi_row EQ true) {
m_secilen_check_box_column = m_column_headers.size() - 1;
}
QVBoxLayout * vertical_layout = new QVBoxLayout(this);
QTreeWidget * widget = new QTreeWidget;
widget->clear();
REGISTER_TREE_WIDGET(widget);
m_tree_widget->setHeaderLabels(m_column_headers);
widget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setLayout(vertical_layout);
resize(p_width, p_height);
SET_ADAK_WINDOW_DEFAULTS(this);
SET_DB_CONN ( database );
FILL_TREE_TABLE();
vertical_layout->addWidget ( m_tree_widget );
vertical_layout->addLayout ( p_h_box_layout );
SET_TREE_WIDGET_DEFAULTS();
}
示例4: kDebug
void InsertSemanticObjectReferenceAction::activated()
{
kDebug(30015) << "create semantic item reference...";
QWidget *widget = new QWidget();
QVBoxLayout *lay = new QVBoxLayout(widget);
widget->setLayout(lay);
lay->setMargin(0);
QLabel *label = new QLabel(i18n("Select the object you want to reference"), widget);
lay->addWidget(label);
QTreeWidget *tree = new QTreeWidget(widget);
KoRdfSemanticTree td = KoRdfSemanticTree::createTree(tree);
td.update(const_cast<KoDocumentRdf*>(m_rdf));
lay->addWidget(tree);
KPageDialog dialog(m_canvas->canvasWidget());
dialog.setCaption(i18n("%1 Options", text())); // TODO add comment (i18nc)
dialog.addPage(widget, QString());
if (dialog.exec() == KPageDialog::Accepted && tree->currentItem()) {
QTreeWidgetItem *item = tree->currentItem();
if (KoRdfSemanticTreeWidgetItem *ditem = dynamic_cast<KoRdfSemanticTreeWidgetItem*>(item)) {
kDebug(30015) << "InsertSemanticObjectReferenceAction::activated... item:" << item;
ditem->insert(m_canvas);
}
}
}
示例5: _to_self
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_header_labels (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTreeWidget *tree = self->v8_to_qobject<QTreeWidget> (Args.This ());
if (tree) {
QTreeWidgetItem *item = tree->headerItem ();
if (Args.Length () && (Args[0]->IsArray ())) {
V8Array array = v8_to_array (Args[0]);
const int Length = array->Length ();
for (int ix = 0; ix < Length; ++ix) {
V8Value value = array->Get (v8::Integer::New (ix));
item->setText (ix, v8_to_qstring (value));
}
}
}
}
return scope.Close (result);
}
示例6: info
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
}
}
}
示例7: qDebug
void mainWin::slotSearchPackages(){
QString pkgSearch = line_search->text();
if(pkgSearch.isEmpty()){ return; }
qDebug() << "Search for package:" <<pkgSearch;
//Get the pointer to the proper treewidget
QTreeWidget *TW = treeNGPkgs;
if( stackedPkgView->currentIndex() == 0 ){ TW = treeMetaPkgs; }
//Make sure the tree widget is not empty
if(TW->topLevelItemCount() < 2){ return; }
//Get the currently selected item
QTreeWidgetItem *CI = TW->currentItem();
bool found=false; bool atTop=false;
if(CI == 0){ atTop=true; }
//Now search the tree, starting at that item
found = performSearch(pkgSearch, TW, CI);
if(!found && !atTop){
//Ask whether to restart the search at the top
if(QMessageBox::Yes == QMessageBox::question(this,tr("No Search Results"),tr("Do you want to continue the search from the top?"),QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){
//Restart the search from the top
found = performSearch(pkgSearch, TW, 0);
}
}
if(!found){
QMessageBox::information(this, tr("No Search Results"), tr("No packages could be found with that search term. Please adjust it and try again.") );
}
qDebug() << " - Search Finished";
}
示例8: createWidget
QWidget* FormUiLoader::createWidget( const QString& className, QWidget* parent, const QString& name)
{
if (className == "QTreeWidget")
{
QTreeWidget* rt = new WidgetWithDragAndDrop<QTreeWidget>( m_dataLoader, parent, name, m_debug);
rt->setDragEnabled( true);
rt->showDropIndicator();
return rt;
}
else if (className == "QListWidget")
{
QListWidget* rt = new WidgetWithDragAndDrop<QListWidget>( m_dataLoader, parent, name, m_debug);
rt->setDragEnabled( true);
rt->showDropIndicator();
return rt;
}
else if (className == "QTableWidget")
{
QTableWidget* rt = new WidgetWithDragAndDrop<QTableWidget>( m_dataLoader, parent, name, m_debug);
rt->setDragEnabled( true);
return rt;
}
else
{
return QUiLoader::createWidget( className, parent, name);
}
}
示例9: addClicked
//@{
void addClicked()
{
QTreeWidgetItem *newRow = 0;
QList<QTreeWidgetItem*> selectedPaths = m_treeView->selectedItems();
if(selectedPaths.empty())
{
newRow = new QTreeWidgetItem( m_treeView );
}
else
{
newRow = new QTreeWidgetItem();
m_treeView->insertTopLevelItem(m_treeView->indexOfTopLevelItem(selectedPaths.last()) + 1, newRow);
}
if(newRow)
{
newRow->setFlags(newRow->flags() | Qt::ItemIsEditable);
m_adapter.updateToRow(newRow, typename MFAdapter::value_type());
updateLabel();
rebuildRowIndexes();
}
Q_EMIT signalChanged();
}
示例10: QTreeWidget
QTreeWidget * ServerListDialog::constructTreeWidget(std::vector<ServerItem *> serverlist)
{
QTreeWidget * treeWidget = new QTreeWidget(this);
QTreeWidgetItem * i;
QStringList stringList;
int index = 0;
treeWidget->setRootIsDecorated(false);
treeWidget->setColumnCount(2);
stringList << "Name" << "IP Address";
treeWidget->setHeaderLabels(stringList);
stringList.clear();
std::vector<ServerItem *>::iterator it;
for(it = serverlist.begin(); it != serverlist.end(); it++)
{
stringList << (*it)->name << (*it)->ipaddress;
i = new QTreeWidgetItem(treeWidget, stringList);
if(index == current_server)
i->setDisabled(true);
if(it == serverlist.begin()) //ugly but its a short list
treeWidget->setCurrentItem(i);
stringList.clear();
index++;
}
return treeWidget;
}
示例11: addToTree
void StatsView::addToTree(std::vector<StatsContainer *>& stats, QTreeWidgetItem *parent) {
QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
for (int i=0; i<stats.size(); ++i) {
StatsContainer *stat = stats[i];
DataContainerTreeItem *boostNode;
if (parent != 0) {
boostNode = new DataContainerTreeItem(parent);
}
else {
boostNode = new DataContainerTreeItem();
statsTree->addTopLevelItem(boostNode);
}
std::string statText = stat->getArg(0);
boostNode->setData(statText);
if (nameMappings.find(statText) != nameMappings.end()) {
statText = nameMappings[statText] + " (" + statText + ")";
} else if (stat->getPrefixList().size() > 0 || stat->getSuffixList().size() > 0) {
if (stat->getPrefixList().size() > 0) {
statText = stat->getPrefixList()[0] + " (" + statText + ")";
} else if (stat->getSuffixList().size() > 0) {
statText = stat->getSuffixList()[0] + " (" + statText + ")";
}
}
boostNode->setText(0, statText.c_str());
}
}
示例12: DataContainerTreeItem
DataContainerTreeItem *StatsView::addFolder(std::string folderName) {
QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
DataContainerTreeItem *item = new DataContainerTreeItem();
statsTree->addTopLevelItem(item);
item->setText(0, folderName.c_str());
return item;
}
示例13: clearTree
void StatsView::clearTree() {
QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
for (int i=0; i<statsTree->topLevelItemCount(); ++i) {
delete statsTree->topLevelItem(i);
--i;
}
}
示例14: usblink_dirlist_callback
void USBLinkTreeWidget::usblink_dirlist_callback(struct usblink_file *file, bool is_error, void *data)
{
if(is_error)
return;
QTreeWidget *w = static_cast<QTreeWidget*>(data);
//End of enumeration or error
if(!file)
{
//Find a dir to fill with entries
for(int i = 0; i < w->topLevelItemCount(); ++i)
if(usblink_dirlist_nested(w->topLevelItem(i)))
return;
// FIXME: If a file is transferred concurrently, this may never be set to false.
if(usblink_queue_size() == 1)
usblink_tree->doing_dirlist = false;
return;
}
//Add directory entry to tree widget
emit usblink_tree->wantToAddTreeItem(itemForUSBLinkFile(file), nullptr);
}
示例15: QTreeWidgetItem
void MainWindow::on_extractBtn_clicked()
{
QString msg = ui->inputTxt->text();
if (msg.isEmpty())
return;
isoExtract->process(msg);
QTreeWidget* tree = ui->resultTree;
tree->clear();
QTreeWidgetItem *parentItem = new QTreeWidgetItem(tree,QStringList(isoExtract->msgType));
QList<QTreeWidgetItem *> items;
QMap<int, IsoField*> isoMsgMap = isoExtract->isoMessage;
QMapIterator<int, IsoField*> i(isoMsgMap);
while (i.hasNext()) {
i.next();
QStringList bitmsg;
bitmsg << QString("Bit %1").arg(i.key()) << i.value()->lengthType << i.value()->value;
items.append(new QTreeWidgetItem((QTreeWidget*)0, bitmsg));
}
parentItem->addChildren(items);
tree->expandItem(parentItem);
// tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
}