本文整理汇总了C++中QVariant::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::setValue方法的具体用法?C++ QVariant::setValue怎么用?C++ QVariant::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::setValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toVariant
QVariant IdListHelper::toVariant(IdList const &list)
{
QVariant v;
v.setValue(list);
return v;
}
示例2: QVBoxLayout
AttributeAccessDlg::AttributeAccessDlg( const QString& title, RTT::SDK::IAttributeAccessPtr attrAccess, RTT::SDK::IObjectFactoryPtr pObjFactory )
: m_attrAccess( attrAccess )
, m_pObjFactory( pObjFactory )
{
setWindowTitle( title );
resize( 600, 500);
using namespace RTT::SDK;
QVBoxLayout *layout = new QVBoxLayout();
m_tree = new QTreeWidget();
m_openAttrAccessDlg = new QPushButton("Attribute Access");
m_openMetaDataDlg = new QPushButton("Metadata");
QStringList headerLabels;
headerLabels.push_back(QString("Name"));
headerLabels.push_back(QString("Value"));
headerLabels.push_back(QString("Type"));
m_tree->setHeaderLabels(headerLabels);
IObjectEnumerationPtr names = attrAccess->GetAttributeNames();
if ( names.isEmpty() )
{
return;
}
for (size_t i=0; i<names->GetItemCount(); ++i)
{
RTT::SDK::IStringPtr name = rtt::commons::dynamic_ptr_cast<RTT::SDK::IString>( names->GetItem(i)->QueryInterface( RTT::SDK::IID_IString ) );
DispVariant valVar = attrAccess->GetAttributeValue(name);
QStringList columns;
columns.push_back(RTT_SDK_UTF8(name));
try
{
if ( valVar.m_type == RTT::SDK::DispVariant::TP_IUNKNOWN )
{
RTT::SDK::IVariantListPtr list = RTT::SDK::interface_cast<RTT::SDK::IVariantList>(valVar.m_pIUnknown);
if ( !list.isEmpty() )
{
QString text;
size_t numItems = list->GetItemCount();
for( size_t n = 0; n<numItems; n++ )
{
DispVariant itemVal = list->GetItem( n );
text += QString("%1;").arg(rttDispTypeConversion(itemVal).toCString());
}
columns.push_back( text );
}
else
{
columns.push_back("Unknown type");
}
}
else
{
switch(valVar.m_type)
{
case DispVariant::TP_FLOAT2:
{
RTT::SDK::FVec2 v2 = rttDispTypeConversion(valVar);
columns.push_back(QString("[%1,%2]").arg(v2[0]).arg(v2[1]));
}
case DispVariant::TP_FLOAT3:
{
RTT::SDK::FVec3 v3 = rttDispTypeConversion(valVar);
columns.push_back(QString("[%1,%2,%3]").arg(v3[0]).arg(v3[1]).arg(v3[2]));
}
case DispVariant::TP_FLOAT4:
{
RTT::SDK::FVec4 v4 = rttDispTypeConversion(valVar);
columns.push_back(QString("[%1,%2,%3,%4]").arg(v4[0]).arg(v4[1]).arg(v4[2]).arg(v4[3]));
}
default:
columns.push_back(rttDispTypeConversion(valVar).toCString());
}
}
}
catch(...)
{
columns.push_back("Invalid type");
}
columns.push_back( typeNames[valVar.m_type] );
QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, columns);
QVariant var;
try
{
var.setValue(rttDispTypeConversion(valVar).toIUnknown());
}
catch(...)
{
var.setValue(IUnknownPtr());
}
pItem->setData(0,Qt::UserRole,var);
RTT::SDK::DispVariant::Type valueType = RTT::SDK::rttDispTypeConversion( valVar ).getType();
if( valueType == RTT::SDK::DispVariant::TP_FLOAT ||
valueType == RTT::SDK::DispVariant::TP_DOUBLE ||
valueType == RTT::SDK::DispVariant::TP_LONG ||
valueType == RTT::SDK::DispVariant::TP_ULONG ||
valueType == RTT::SDK::DispVariant::TP_BOOL )
//.........这里部分代码省略.........