本文整理汇总了C++中QTreeWidgetItem::treeWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::treeWidget方法的具体用法?C++ QTreeWidgetItem::treeWidget怎么用?C++ QTreeWidgetItem::treeWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::treeWidget方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usblink_dirlist_callback_nested
void USBLinkTreeWidget::usblink_dirlist_callback_nested(struct usblink_file *file, bool is_error, void *data)
{
QTreeWidgetItem *w = static_cast<QTreeWidgetItem*>(data);
//End of enumeration or error
if(!file)
{
w->setData(1, Qt::UserRole, QVariant(true)); //Dir is now filled
if(!is_error)
{
//Find a dir to fill with entries
for(int i = 0; i < w->treeWidget()->topLevelItemCount(); ++i)
if(usblink_dirlist_nested(w->treeWidget()->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 item (parent)
emit usblink_tree->wantToAddTreeItem(itemForUSBLinkFile(file), w);
}
示例2: usblink_delete_callback
void USBLinkTreeWidget::usblink_delete_callback(int progress, void *data)
{
// Only remove the treewidget item if the delete operation was successful
if(progress != 100)
return;
QTreeWidgetItem *w = static_cast<QTreeWidgetItem*>(data);
if(w->parent())
w->parent()->takeChild(w->parent()->indexOfChild(w));
else
w->treeWidget()->takeTopLevelItem(w->treeWidget()->indexOfTopLevelItem(w));
}
示例3:
QTreeWidget *QTreeWidgetItemProto::treeWidget() const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->treeWidget();
return 0;
}
示例4: checkItemParentsNotVisible
void KTreeWidgetSearchLine::checkItemParentsNotVisible(QTreeWidget *treeWidget)
{
QTreeWidgetItemIterator it(treeWidget);
for (; *it; ++it) {
QTreeWidgetItem *item = *it;
item->treeWidget()->setItemHidden(item, !itemMatches(item, k->search));
}
}
示例5: QTreeWidgetItem
QTreeWidgetItem * QtHelpConfig::addTableItem(const QString &icon, const QString &name,
const QString &path, const QString &ghnsStatus)
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_configWidget->qchTable);
item->setIcon(NameColumn, QIcon::fromTheme(icon));
item->setText(NameColumn, name);
item->setToolTip(NameColumn, name);
item->setText(PathColumn, path);
item->setToolTip(PathColumn, path);
item->setText(IconColumn, icon);
item->setText(GhnsColumn, ghnsStatus);
QWidget *ctrlWidget = new QWidget(item->treeWidget());
ctrlWidget->setLayout(new QHBoxLayout(ctrlWidget));
QToolButton *modifyBtn = new QToolButton(item->treeWidget());
modifyBtn->setIcon(QIcon::fromTheme("document-edit"));
modifyBtn->setToolTip(i18n("Modify"));
connect(modifyBtn, &QPushButton::clicked, this, [=](){
modify(item);
});
QToolButton *removeBtn = new QToolButton(item->treeWidget());
removeBtn->setIcon(QIcon::fromTheme("entry-delete"));
removeBtn->setToolTip(i18n("Delete"));
if (item->text(GhnsColumn) != "0") {
// KNS3 currently does not provide API to uninstall entries
// just removing the files results in wrong installed states in the KNS3 dialog
// TODO: add API to KNS to remove files without UI interaction
removeBtn->setEnabled(false);
removeBtn->setToolTip(tr("Please uninstall this via GHNS"));
} else {
connect(removeBtn, &QPushButton::clicked, this, [=](){
remove(item);
});
}
ctrlWidget->layout()->addWidget(modifyBtn);
ctrlWidget->layout()->addWidget(removeBtn);
m_configWidget->qchTable->setItemWidget(item, ConfigColumn, ctrlWidget);
return item;
}
示例6: deleteItem
void *ListView::processEvent(Event *e)
{
if (e->type() == EventCommandExec){
CommandDef *cmd = (CommandDef*)(e->param());
if ((cmd->id == CmdListDelete) && (cmd->menu_id == MenuListView)){
QTreeWidgetItem *item = (QTreeWidgetItem*)(cmd->param);
if (item->treeWidget() == this){
emit deleteItem(item);
return e->param();
}
}
}
return NULL;
}
示例7: usblink_dirlist_callback_nested
void MainWindow::usblink_dirlist_callback_nested(struct usblink_file *file, void *data)
{
QTreeWidgetItem *w = static_cast<QTreeWidgetItem*>(data);
//End of enumeration or error
if(!file)
{
refresh_filebrowser = true;
w->setData(1, Qt::UserRole, QVariant(true)); //Dir is now filled
//Find a dir to fill with entries
for(int i = 0; i < w->treeWidget()->topLevelItemCount(); ++i)
if(usblink_dirlist_nested(w->treeWidget()->topLevelItem(i)))
return;
return;
}
//Add directory entry to tree widget item (parent)
QTreeWidgetItem *item = new QTreeWidgetItem({QString::fromUtf8(file->filename), file->is_dir ? "" : naturalSize(file->size)});
item->setData(0, Qt::UserRole, QVariant(file->is_dir));
item->setData(1, Qt::UserRole, QVariant(false));
w->addChild(item);
}
示例8: appendMaterialProperty
QWidget* MainWindow::appendMaterialProperty(const Material::SerializedData& data, QTreeWidgetItem* parent)
{
QTreeWidgetItem* child = new QTreeWidgetItem(parent);
parent->addChild(child);
if ( data.m_propertyType == Material::SerializedData::PROPERTY_TYPE_COLOR )
{
assert(data.m_childProperties.size() == 3);
ColorPickerButton* colorPicker = new ColorPickerButton(child->treeWidget());
colorPicker->setColor(QColor((int)(data.m_childProperties[0].m_value * 255),
(int)(data.m_childProperties[1].m_value * 255),
(int)(data.m_childProperties[2].m_value * 255)));
child->treeWidget()->setItemWidget(child, 0, colorPicker);
connect(colorPicker, SIGNAL(beginUserInteraction(void)),
ui->glWidget, SLOT(onBeginUserInteraction(void)));
connect(colorPicker, SIGNAL(endUserInteraction(void)),
ui->glWidget, SLOT(onEndUserInteraction(void)));
connect(colorPicker, SIGNAL(colorChanged(QColor)),
this, SLOT(onMaterialColorChanged(QColor)));
return colorPicker;
}
示例9: itemAt
void
rightclick_tree_widget::mousePressEvent(QMouseEvent *event) {
if (event->button() != Qt::RightButton) {
QTreeWidget::mousePressEvent(event);
return;
}
QTreeWidgetItem *item = itemAt(event->pos());
if (item) {
#if QT_VERSION >= 0x040200
gui->expand_all_elements(item, !item->isExpanded());
#else // QT_VERSION >= 0x040200
gui->expand_all_elements(item, !item->treeWidget()->isItemExpanded(item));
#endif // QT_VERSION >= 0x040200
}
}
示例10: copyContents
void TreeWidgetEditor::copyContents(QTreeWidgetItem *sourceItem, QTreeWidgetItem *destItem)
{
int colCount = sourceItem->treeWidget()->columnCount();
for (int i = 0; i < sourceItem->childCount(); i++) {
QTreeWidgetItem *origItem = sourceItem->child(i);
QTreeWidgetItem *item = new QTreeWidgetItem(destItem);
item->setFlags(item->flags() | Qt::ItemIsEditable);
for (int j = 0; j < colCount; j++) {
item->setText(j, origItem->text(j));
item->setIcon(j, origItem->icon(j));
}
item->treeWidget()->setItemExpanded(item, true);
copyContents(origItem, item);
}
}
示例11:
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_item_tree_widget (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) {
QTreeWidget *tree = item->treeWidget ();
result = self->create_v8_qwidget (tree);
}
}
return scope.Close (result);
}
示例12: text
virtual bool operator<(const QTreeWidgetItem & other) const
{
int col = other.treeWidget()->sortColumn();
EventListItem* eli = (EventListItem*) & other;
switch (col)
{
case 0:
return event.tick() < eli->event.tick();
break;
case 1:
return part->tick() + event.tick() < (eli->part->tick() + eli->event.tick());
break;
case 2:
return text(col).localeAwareCompare(other.text(col)) < 0;
break;
case 3:
return part->track()->outChannel() < eli->part->track()->outChannel();
break;
case 4:
return event.dataA() < eli->event.dataA();
break;
case 5:
return event.dataB() < eli->event.dataB();
break;
case 6:
return event.dataC() < eli->event.dataC();
break;
case 7:
return event.lenTick() < eli->event.lenTick();
break;
case 8:
return text(col).localeAwareCompare(other.text(col)) < 0;
break;
default:
break;
}
return 0;
}
示例13: if
/* Fill a single protocol tree item with its string value and set its color. */
static void
proto_tree_draw_node(proto_node *node, gpointer data)
{
field_info *fi = PNODE_FINFO(node);
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
gboolean is_branch;
/* dissection with an invisible proto tree? */
g_assert(fi);
if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items)
return;
// Fill in our label
/* was a free format label produced? */
if (fi->rep) {
label_ptr = fi->rep->representation;
}
else { /* no, make a generic label */
label_ptr = label_str;
proto_item_fill_label(fi, label_str);
}
if (node->first_child != NULL) {
is_branch = TRUE;
g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types);
}
else {
is_branch = FALSE;
}
if (PROTO_ITEM_IS_GENERATED(node)) {
if (PROTO_ITEM_IS_HIDDEN(node)) {
label_ptr = g_strdup_printf("<[%s]>", label_ptr);
} else {
label_ptr = g_strdup_printf("[%s]", label_ptr);
}
} else if (PROTO_ITEM_IS_HIDDEN(node)) {
label_ptr = g_strdup_printf("<%s>", label_ptr);
}
QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data;
QTreeWidgetItem *item;
ProtoTree *proto_tree = qobject_cast<ProtoTree *>(parentItem->treeWidget());
item = new QTreeWidgetItem(parentItem, 0);
// Set our colors.
QPalette pal = QApplication::palette();
if (fi && fi->hfinfo) {
if(fi->hfinfo->type == FT_PROTOCOL) {
item->setData(0, Qt::BackgroundRole, pal.alternateBase());
}
if((fi->hfinfo->type == FT_FRAMENUM) ||
(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) {
QFont font = item->font(0);
item->setData(0, Qt::ForegroundRole, pal.link());
font.setUnderline(true);
item->setData(0, Qt::FontRole, font);
if (fi->hfinfo->type == FT_FRAMENUM) {
proto_tree->emitRelatedFrame(fi->value.value.uinteger);
}
}
}
// XXX - Add routines to get our severity colors.
if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) {
switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) {
case(PI_COMMENT):
item->setData(0, Qt::BackgroundRole, expert_color_comment);
break;
case(PI_CHAT):
item->setData(0, Qt::BackgroundRole, expert_color_chat);
break;
case(PI_NOTE):
item->setData(0, Qt::BackgroundRole, expert_color_note);
break;
case(PI_WARN):
item->setData(0, Qt::BackgroundRole, expert_color_warn);
break;
case(PI_ERROR):
item->setData(0, Qt::BackgroundRole, expert_color_error);
break;
default:
g_assert_not_reached();
}
item->setData(0, Qt::ForegroundRole, expert_color_foreground);
}
item->setText(0, label_ptr);
item->setData(0, Qt::UserRole, qVariantFromValue(fi));
if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) {
g_free(label_ptr);
}
//.........这里部分代码省略.........