本文整理汇总了C++中XTreeWidgetItem::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ XTreeWidgetItem::setData方法的具体用法?C++ XTreeWidgetItem::setData怎么用?C++ XTreeWidgetItem::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XTreeWidgetItem 的用法示例。
在下文中一共展示了XTreeWidgetItem::setData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sFillList
void dspInvoiceRegister::sFillList()
{
display::sFillList();
list()->expandAll();
// calculate subtotals and grand total for debit and credit columns and add rows for them
double debittotal = 0.0;
double credittotal = 0.0;
for (int i = 0; i < list()->topLevelItemCount(); i++)
{
double debitsum = 0.0;
double creditsum = 0.0;
XTreeWidgetItem *item = 0;
for (int j = 0; j < list()->topLevelItem(i)->childCount(); j++)
{
item = list()->topLevelItem(i)->child(j);
// qDebug("in loop @ %d %p", j, item);
if (item)
{
debitsum += item->rawValue("debit").toDouble();
creditsum += item->rawValue("credit").toDouble();
debittotal += item->rawValue("debit").toDouble();
credittotal += item->rawValue("credit").toDouble();
}
}
if (item)
{
// qDebug("adding subtotal %p", item);
item = new XTreeWidgetItem(list()->topLevelItem(i), -1, -1, tr("Subtotal"));
item->setData(list()->column("debit"), Qt::EditRole, formatMoney(debitsum));
item->setData(list()->column("credit"), Qt::EditRole, formatMoney(creditsum));
}
}
XTreeWidgetItem *item = new XTreeWidgetItem(list(), -1, -1, tr("Total"));
item->setData(list()->column("debit"), Qt::EditRole, formatMoney(debittotal));
item->setData(list()->column("credit"), Qt::EditRole, formatMoney(credittotal));
}
开发者ID:,项目名称:,代码行数:37,代码来源:
示例2: populate
/*!
Populates the list of setup widgets filtered by selectd module. Selects the first item
when \a first is true.
*/
void setup::populate(bool first)
{
_tree->clear();
while (_stack->count())
{
QWidget* w = _stack->widget(0);
_stack->removeWidget(w);
w = 0;
}
XTreeWidgetItem* _configItem = new XTreeWidgetItem(_tree, 0, -1, tr("Configure"));
XTreeWidgetItem* _mapItem = new XTreeWidgetItem(_tree, 0, -1, tr("Accounting Mappings"));
XTreeWidgetItem* _masterItem = new XTreeWidgetItem(_tree, 0, -1, tr("Master Information"));
QBrush disabled(Qt::gray);
XTreeWidgetItem* parent = 0;
ItemProps ip;
int id = 0;
QMapIterator<QString, ItemProps> i(_itemMap);
while (i.hasNext())
{
id++;
i.next();
ip = i.value();
_itemMap[i.key()].index = -1;
_itemMap[i.key()].id = -1;
if (_modules->currentIndex() == 0 ||
_modules->itemData(_modules->currentIndex()).toInt() & ip.modules)
{
if (ip.type == Configure)
parent = _configItem;
else if (ip.type == AccountMapping)
parent = _mapItem;
else
parent = _masterItem;
// Set the item on the list
XTreeWidgetItem* item = new XTreeWidgetItem(parent, id);
item->setData(0, Qt::DisplayRole, QVariant(ip.title));
item->setData(0, Xt::RawRole, QVariant(i.key()));
if (!ip.enabled)
{
item->setFlags(Qt::NoItemFlags);
item->setForeground(0,disabled);
}
parent->addChild(item);
_itemMap[i.key()].id = id;
}
}
if (!_configItem->childCount())
_tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_configItem));
if (!_mapItem->childCount())
_tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_mapItem));
if (!_masterItem->childCount())
_tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_masterItem));
_tree->expandAll();
if (_tree->topLevelItemCount() && first)
setCurrentIndex(_tree->topLevelItem(0));
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:70,代码来源:setup.cpp
注:本文中的XTreeWidgetItem::setData方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论