本文整理汇总了C++中QTreeWidgetItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::data方法的具体用法?C++ QTreeWidgetItem::data怎么用?C++ QTreeWidgetItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
HierarchyTreeControlMimeData::HierarchyTreeControlMimeData(const QList<QTreeWidgetItem*> items)
{
for (QList<QTreeWidgetItem*>::const_iterator iter = items.begin(); iter != items.end(); ++iter)
{
QTreeWidgetItem* item = (*iter);
QVariant data = item->data(ITEM_ID);
HierarchyTreeNode::HIERARCHYTREENODEID id = data.toInt();
Logger::Debug("HierarchyTreeNode::HIERARCHYTREENODEID %d", id);
HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator it = std::find(this->items.begin(), this->items.end(), id);
if (it == this->items.end())
this->items.push_back(id);
}
}
示例2: s
void EditDrumset::updateList2()
{
for (int i = 0; i < pitchList->topLevelItemCount(); ++i) {
QTreeWidgetItem* item = pitchList->topLevelItem(i);
int pitch = item->data(0, Qt::UserRole).toInt();
if (nDrumset.shortcut(pitch) == 0)
item->setText(COL_SHORTCUT, "");
else {
QString s(QChar(nDrumset.shortcut(pitch)));
item->setText(COL_SHORTCUT, s);
}
item->setText(COL_NAME, qApp->translate("drumset", qPrintable(nDrumset.name(pitch))));
item->setData(0, Qt::UserRole, pitch);
}
}
示例3: UpdateTrackVolumeAnnotation
void InfoTreeWidget::UpdateTrackVolumeAnnotation(Layer *layer, const QVariantMap &info)
{
for (int i = 0; i < this->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = this->topLevelItem(i);
if (item)
{
QVariantMap map = item->data(1, Qt::UserRole).toMap();
if (map.contains("Object") && map["Object"].value<QObject*>() == layer)
{
item->setText(1, QString("%1 \t%2").arg(info["label"].toInt()).arg(info["name"].toString()));
}
}
}
}
示例4: excludeFromExecution
void LibraryTreeWidget::excludeFromExecution(bool checked)
{
if (selectedItems().empty() == true)
return;
QTreeWidgetItem* item = selectedItems()[0];
QMap<QString, QVariant> data = item->data(0, Qt::UserRole).toMap();
data["excludeFromExecution"] = checked;
item->setData(0, Qt::UserRole, data);
item->setIcon(0, IconLibrary::instance().icon(0, checked ? "lua with stop" : "lua"));
dependencyGraph_.setExcludeFromExecution(data["filename"].toString(), checked);
}
示例5: foreach
VCXYPadPreset *VCXYPadProperties::getSelectedPreset()
{
if (m_presetsTree->selectedItems().isEmpty())
return NULL;
QTreeWidgetItem* item = m_presetsTree->selectedItems().first();
if (item != NULL)
{
quint8 presetID = item->data(0, Qt::UserRole).toUInt();
foreach(VCXYPadPreset* preset, m_presetList)
{
if (preset->m_id == presetID)
return preset;
}
}
示例6: updateTextFormatDisplay
void EditorPage::updateTextFormatDisplay()
{
QTreeWidgetItem *item = ui->textFormats->currentItem();
bool canEdit = item && item->data(0, TextFormatConfigKeyRole).isValid();
if (!canEdit)
return;
QTextCharFormat format = constructTextFormat();
item->setData( 0, TextFormatRole, QVariant::fromValue(format) );
if (item != mCommonTextFormatItem)
updateTextFormatDisplay( item );
else
updateTextFormatDisplayCommons();
}
示例7: invisibleRootItem
/**
* Get the QTreeWidgetItem associated with the given undo command (work order). Returns NULL if
* none found or given NULL.
*
* @param undoCommand A work order
* @return The QTreeWidgetItem that represents (is associated with) the undoCommand
*/
QTreeWidgetItem *HistoryTreeWidget::undoCommandToTreeItem(const QUndoCommand *undoCommand) {
QTreeWidgetItem *result = NULL;
if (undoCommand) {
for (int i = invisibleRootItem()->childCount() - 1; !result && i >= 0; i--) {
QTreeWidgetItem *item = invisibleRootItem()->child(i);
WorkOrder *workOrder = item->data(0, Qt::UserRole).value<WorkOrder *>();
if (undoCommand == workOrder)
result = item;
}
}
return result;
}
示例8:
QSet <quint32> VCSpeedDialProperties::functions() const
{
QSet <quint32> set;
for (int i = 0; i < m_tree->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = m_tree->topLevelItem(i);
Q_ASSERT(item != NULL);
QVariant var = item->data(COL_NAME, PROP_ID);
if (var.isValid() == true)
set << var.toUInt();
}
return set;
}
示例9: fixtureItem
QTreeWidgetItem* EFXEditor::fixtureItem(EFXFixture* ef)
{
QTreeWidgetItemIterator it(m_tree);
while (*it != NULL)
{
QTreeWidgetItem* item = *it;
EFXFixture* ef_item = reinterpret_cast<EFXFixture*>
(item->data(0, Qt::UserRole).toULongLong());
if (ef_item == ef)
return item;
++it;
}
return NULL;
}
示例10: expandMessages
void ProtobufTree::expandMessages(QTreeWidgetItem* item) {
if (!item) {
item = invisibleRootItem();
}
expandItem(item);
for (int i = 0; i < item->childCount(); ++i) {
QTreeWidgetItem* child = item->child(i);
if (child->data(Column_Tag, IsMessageRole).toBool()) {
expandMessages(child);
}
}
}
示例11: closeLibrary
void LibraryWidget::closeLibrary(const QUrl &projectThingUrl)
{
int toplevelItems = ui->treeWidget->topLevelItemCount();
for(int i=1; i <= toplevelItems; i++) {
QTreeWidgetItem *root = ui->treeWidget->topLevelItem(i);
QUrl openProject = (root->data(0,BibGlobals::Role_ProjectThing).toUrl());
if(openProject == projectThingUrl) {
QTreeWidgetItem *closedItem = ui->treeWidget->takeTopLevelItem(i);
delete closedItem;
break;
}
}
}
示例12: listChanged
void CheatEditorWindow::listChanged() {
QList<QTreeWidgetItem*> items = list->selectedItems();
if(items.count() > 0) {
QTreeWidgetItem *item = items[0];
unsigned n = item->data(0, Qt::UserRole).toUInt();
SNES::Cheat::cheat_t code;
SNES::cheat.get(n, code);
descEdit->setText(utf8() << code.desc);
codeEdit->setText(utf8() << code.code);
}
syncUi();
}
示例13: onEditButtonClicked
void LinkList::onEditButtonClicked()
{
QTreeWidgetItem *item =
linkTree->currentItem();
if( item == NULL )
return;
bool ok;
uint32 id = item->data( 3, Qt::UserRole ).toUInt( &ok );
if( !ok )
return;
linkEditor->setLinkId( id );
linkEditor->show();
}
示例14: moveToMostActiveItem
void TreeWidget::moveToMostActiveItem()
{
QTreeWidgetItem* mostActive = 0;
QTreeWidgetItemIterator it(this, QTreeWidgetItemIterator::Unselected);
while (*it) {
QTreeWidgetItem* item = *it;
if (d.highlightedItems.contains(item)) {
// we found a channel hilight or PM to us
setCurrentItem(item);
return;
}
// as a backup, store the most active window with any sort of activity
const int badge = item->data(1, TreeRole::Badge).toInt();
if (badge > 0 && (!mostActive || mostActive->data(1, TreeRole::Badge).toInt() < badge))
mostActive = item;
it++;
}
if (mostActive)
setCurrentItem(mostActive);
}
示例15: size
void QgsVectorGradientColorRampV2Dialog::updatePreview()
{
// update ramp stops from the tree widget
QgsGradientStopsList stops;
if ( groupStops->isChecked() )
{
int count = treeStops->topLevelItemCount();
for ( int i = 0; i < count; i++ )
{
QTreeWidgetItem* item = treeStops->topLevelItem( i );
double offset = item->data( 0, StopOffsetRole ).toDouble();
QColor color = item->data( 0, StopColorRole ).value<QColor>();
stops.append( QgsGradientStop( offset, color ) );
}
}
mRamp->setStops( stops );
// generate the preview
QSize size( 300, 40 );
lblPreview->setPixmap( QgsSymbolLayerV2Utils::colorRampPreviewPixmap( mRamp, size ) );
btnColor1->setColor( mRamp->color1() );
btnColor2->setColor( mRamp->color2() );
}