本文整理汇总了C++中PropertyItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyItem::data方法的具体用法?C++ PropertyItem::data怎么用?C++ PropertyItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyItem
的用法示例。
在下文中一共展示了PropertyItem::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant PropertyModel::data ( const QModelIndex & index, int role ) const
{
if (!index.isValid())
return QVariant();
PropertyItem *item = static_cast<PropertyItem*>(index.internalPointer());
return item->data(index.column(), role);
}
示例2: paintProperty
void PropertyRendererPixmap::paintProperty ( QPainter * painter, const QStyleOptionViewItem &option, const QModelIndex &index ) {
static const int i = 16;
PropertyItem *data = modelIndexToData( index );
if ( data == 0 )
return ;
QRect rect = option.rect;
QRect pixRec = QRect( rect.left() + i / 2, rect.top() + ( rect.height() - i ) / 2, i, i );
QPixmap pix = getPixmapFromQVariant( data->data() );
painter->drawPixmap( pixRec, pix );
}
示例3: setData
bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, int role)
{
if (!index.isValid())
return false;
// we check whether the data has really changed, otherwise we ignore it
if (role == Qt::EditRole) {
PropertyItem *item = static_cast<PropertyItem*>(index.internalPointer());
QVariant data = item->data(index.column(), role);
if (data.type() == QVariant::Double && value.type() == QVariant::Double) {
// since we store some properties as floats we get some round-off
// errors here. Thus, we use an epsilon here.
double d = data.toDouble();
double v = value.toDouble();
if (fabs(d-v) > FLT_EPSILON)
return item->setData(value);
}
else if (data != value)
return item->setData(value);
}
return true;
}