本文整理汇总了C++中QtVariantProperty::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QtVariantProperty::setEnabled方法的具体用法?C++ QtVariantProperty::setEnabled怎么用?C++ QtVariantProperty::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QtVariantProperty
的用法示例。
在下文中一共展示了QtVariantProperty::setEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
QtProperty *CrossCommonPropertyGroup::extrackBaseProperty(QtVariantPropertyManager *manager,
QHash<QString, QtVariantProperty *> &propertyTable)
{
QtProperty *parameters;
QtVariantProperty *item;
parameters = manager->addProperty(QtVariantPropertyManager::groupTypeId(),
QString(QObject::tr("基本属性")));
#ifdef QT_DEBUG
item = manager->addProperty(QVariant::Int, QString(QObject::tr("id(发布版本无此项)")));
item->setValue("0");
item->setEnabled(false);
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/id", item);
#endif
item = manager->addProperty(QVariant::String, QString(QObject::tr("图名")));
item->setValue(QObject::tr("交会图"));
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/title", item);
item = manager->addProperty(QVariant::Double, QString(QObject::tr("宽度")));
item->setValue(400);
item->setAttribute(QLatin1String("minimum"), 0);
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/width", item);
item = manager->addProperty(QVariant::Double, QString(QObject::tr("高度")));
item->setValue(300);
item->setAttribute(QLatin1String("minimum"), 0);
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/height", item);
item = manager->addProperty(QVariant::Double, QString(QObject::tr("x")));
item->setValue(0);
item->setAttribute(QLatin1String("minimum"), 0);
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/x", item);
item = manager->addProperty(QVariant::Double, QString(QObject::tr("y")));
item->setValue(0);
item->setAttribute(QLatin1String("minimum"), 0);
parameters->addSubProperty(item);
propertyTable.insert("/map_key/base/y", item);
return parameters;
}
示例2: addClassProperties
void ObjectControllerPrivate::addClassProperties(const QMetaObject *metaObject)
{
if (!metaObject)
return;
addClassProperties(metaObject->superClass());
QtProperty *classProperty = m_classToProperty.value(metaObject);
if (!classProperty) {
QString className = QLatin1String(metaObject->className());
classProperty = m_manager->addProperty(QtVariantPropertyManager::groupTypeId(), className);
m_classToProperty[metaObject] = classProperty;
m_propertyToClass[classProperty] = metaObject;
for (int idx = metaObject->propertyOffset(); idx < metaObject->propertyCount(); idx++) {
QMetaProperty metaProperty = metaObject->property(idx);
int type = metaProperty.userType();
QtVariantProperty *subProperty = 0;
if (!metaProperty.isReadable()) {
subProperty = m_readOnlyManager->addProperty(QVariant::String, QLatin1String(metaProperty.name()));
subProperty->setValue(QLatin1String("< Non Readable >"));
} else if (metaProperty.isEnumType()) {
if (metaProperty.isFlagType()) {
subProperty = m_manager->addProperty(QtVariantPropertyManager::flagTypeId(), QLatin1String(metaProperty.name()));
QMetaEnum metaEnum = metaProperty.enumerator();
QMap<int, bool> valueMap;
QStringList flagNames;
for (int i = 0; i < metaEnum.keyCount(); i++) {
int value = metaEnum.value(i);
if (!valueMap.contains(value) && isPowerOf2(value)) {
valueMap[value] = true;
flagNames.append(QLatin1String(metaEnum.key(i)));
}
subProperty->setAttribute(QLatin1String("flagNames"), flagNames);
subProperty->setValue(flagToInt(metaEnum, metaProperty.read(m_object).toInt()));
}
} else {
subProperty = m_manager->addProperty(QtVariantPropertyManager::enumTypeId(), QLatin1String(metaProperty.name()));
QMetaEnum metaEnum = metaProperty.enumerator();
QMap<int, bool> valueMap; // dont show multiple enum values which have the same values
QStringList enumNames;
for (int i = 0; i < metaEnum.keyCount(); i++) {
int value = metaEnum.value(i);
if (!valueMap.contains(value)) {
valueMap[value] = true;
enumNames.append(QLatin1String(metaEnum.key(i)));
}
}
subProperty->setAttribute(QLatin1String("enumNames"), enumNames);
subProperty->setValue(enumToInt(metaEnum, metaProperty.read(m_object).toInt()));
}
} else if (m_manager->isPropertyTypeSupported(type)) {
if (!metaProperty.isWritable())
subProperty = m_readOnlyManager->addProperty(type, QLatin1String(metaProperty.name()) + QLatin1String(" (Non Writable)"));
if (!metaProperty.isDesignable())
subProperty = m_readOnlyManager->addProperty(type, QLatin1String(metaProperty.name()) + QLatin1String(" (Non Designable)"));
else
subProperty = m_manager->addProperty(type, QLatin1String(metaProperty.name()));
subProperty->setValue(metaProperty.read(m_object));
} else {
subProperty = m_readOnlyManager->addProperty(QVariant::String, QLatin1String(metaProperty.name()));
subProperty->setValue(QLatin1String("< Unknown Type >"));
subProperty->setEnabled(false);
}
classProperty->addSubProperty(subProperty);
m_propertyToIndex[subProperty] = idx;
m_classToIndexToProperty[metaObject][idx] = subProperty;
}
} else {
updateClassProperties(metaObject, false);
}
m_topLevelProperties.append(classProperty);
m_browser->addProperty(classProperty);
}
示例3: timerEvent
void DataWidget::timerEvent(QTimerEvent* event) {
(void)event;
string path;
// go throud the add list
addMutex.lock();
ignore_change = true;
map<unsigned long, paramWrapper>::iterator it;
map<unsigned long, paramWrapper> tmpList;
DataItem *item;
//DataItem *item2;
for(it=addList.begin(); it!=addList.end(); ++it) {
it->second.dataPackage = dataBroker->getDataPackage(it->second.info.dataId);
for(unsigned int i = 0; i < it->second.dataPackage.size(); ++i) {
std::map<QString, QVariant> attr;
attr["singleStep"] = 0.01;
attr["decimals"] = 7;
path = "";
path.append(it->second.info.groupName);
path.append("/");
path.append(it->second.info.dataName);
if(it->second.dataPackage.size() > 1) {
path.append("/");
path.append(it->second.dataPackage[i].getName());
}
item = &it->second.dataPackage[i];
QtVariantProperty *guiElem;
switch(item->type) {
case data_broker::FLOAT_TYPE:
guiElem = pDialog->addGenericProperty(path,
QVariant::Double,
item->f, &attr);
break;
case data_broker::DOUBLE_TYPE:
guiElem = pDialog->addGenericProperty(path,
QVariant::Double,
item->d, &attr);
break;
case data_broker::INT_TYPE:
guiElem = pDialog->addGenericProperty(path, QVariant::Int,
item->i);
break;
case data_broker::LONG_TYPE:
guiElem = pDialog->addGenericProperty(path, QVariant::Int,
(int)item->l);
break;
case data_broker::BOOL_TYPE:
guiElem = pDialog->addGenericProperty(path, QVariant::Bool,
item->b);
break;
case data_broker::STRING_TYPE:
guiElem = pDialog->addGenericProperty(path, QVariant::String,
QString::fromStdString(item->s));
break;
default:
guiElem = 0;
}
if(guiElem &&
!(it->second.info.flags & data_broker::DATA_PACKAGE_WRITE_FLAG)) {
guiElem->setEnabled(false);
}
it->second.guiElements.push_back(guiElem);
if(!it->second.guiElements.empty()) {
listMutex.lock();
paramList[it->first] = it->second;
guiToWrapper[guiElem] = ¶mList[it->first];//it->second;
//guiToWrapper[&it->second.guiElements] = it->second;
listMutex.unlock();
}
}
if(it->second.guiElements.empty()) {
tmpList[it->first] = it->second;
}
}
addList.clear();
addList = tmpList;
ignore_change = false;
addMutex.unlock();
// and check for updates
changeMutex.lock();
ignore_change = true;
while(changeList.size() > 0) {
it = paramList.find(*changeList.begin());
if(it != paramList.end() && !it->second.guiElements.empty()) {
for(unsigned int i = 0; i < it->second.guiElements.size(); ++i) {
QtVariantProperty *guiElem = it->second.guiElements[i];
item = &it->second.dataPackage[i];
//item2 = &guiToWrapper[it->second.guiElements.front()]->dataPackage[i];
switch(item->type) {
case data_broker::DOUBLE_TYPE:
guiElem->setValue(QVariant(item->d));
//item2->d = item->d;
break;
case data_broker::FLOAT_TYPE:
guiElem->setValue(QVariant(item->f));
//item2->f = item->f;
//.........这里部分代码省略.........
示例4: canvasSelectionChanged
void PropertiesEditorDialog::canvasSelectionChanged()
{
// Clear the existing properties.
QMap<QtProperty *, QString>::ConstIterator itProp =
m_property_to_id.constBegin();
while (itProp != m_property_to_id.constEnd())
{
delete itProp.key();
itProp++;
}
m_property_to_id.clear();
m_id_to_property.clear();
if (!m_canvas)
{
return;
}
QList<QGraphicsSvgItem *> list = m_canvas->selectedGeneralItems();
QObject *item = m_canvas;
int firstProperty = Canvas::staticMetaObject.propertyOffset();
bool canvasItemProperties = false;
if (list.count() > 0)
{
item = list.front();
canvasItemProperties = true;
firstProperty = QGraphicsSvgItem::staticMetaObject.propertyOffset();
}
QtVariantProperty *property = NULL;
const QMetaObject* metaObject = item->metaObject();
QStringList properties;
for(int i = firstProperty; i < metaObject->propertyCount(); ++i)
{
//qDebug("== %s", metaObject->property(i).name());
// Justin: Get rid of the first 2 special properties for QGraphicsSvgItems; it's meaningless to display them.
if (QString(metaObject->property(i).name()).compare(QString("elementId")) == 0 || QString(metaObject->property(i).name()).compare(QString("maximumCacheSize")) == 0) continue;
const QMetaProperty& prop = metaObject->property(i);
int type = prop.userType();
if (type == QVariant::UInt)
{
type = QVariant::Int;
}
//qDebug("## %s, %d, %s", prop.name(), prop.userType(), item->property(prop.name()).typeName());
if (prop.isEnumType())
{
property = m_variant_manager->addProperty(QtVariantPropertyManager::enumTypeId(), QLatin1String(prop.name()));
QMetaEnum metaEnum = prop.enumerator();
QMap<int, bool> valueMap; // dont show multiple enum values which have the same values
QStringList enumNames;
for (int i = 0; i < metaEnum.keyCount(); i++) {
int value = metaEnum.value(i);
if (!valueMap.contains(value)) {
valueMap[value] = true;
enumNames.append(QLatin1String(metaEnum.key(i)));
}
}
property->setAttribute(QLatin1String("enumNames"), enumNames);
//qDebug() << prop.name() << "= " << item->property(prop.name()).value<dunnart::Connector::RoutingType>();
int enumValueIndex = *reinterpret_cast<const int *>
(item->property(prop.name()).constData());
property->setValue(metaEnum.value(enumValueIndex));
}
else if (m_variant_manager->isPropertyTypeSupported(type))
{
if (!prop.isWritable())
{
property = m_read_only_manager->addProperty(type, QLatin1String(prop.name()) + QLatin1String(" (read-only)"));
}
else
{
property = m_variant_manager->addProperty(type, QLatin1String(prop.name()));
}
property->setValue(item->property(prop.name()));
}
else
{
property = m_read_only_manager->addProperty(QVariant::String, QLatin1String(prop.name()));
property->setValue(QLatin1String("< Unknown Type >"));
property->setEnabled(false);
}
Q_ASSERT(property);
//property->setAttribute(QLatin1String("minimum"), 0);
//property->setAttribute(QLatin1String("maximum"), 100);
addProperty(property, prop.name());
}
QList<QByteArray> propertyList = item->dynamicPropertyNames();
for (int i = 0; i < propertyList.size(); ++i)
{
//qDebug("-- %s", propertyList.at(i).constData());
const char *propName = propertyList.at(i).constData();
const QVariant& propVariant = item->property(propName);
//.........这里部分代码省略.........
示例5: addClassProperties
//.........这里部分代码省略.........
// Note: Get the var member name and check if we want it to be writable (Enabled)
QString memberVarName = QLatin1String(metaProperty.name());
bool b_SetEnabled = true;
// Special case for enabling or disabling editing
QString ememberVarName = "e" + QLatin1String(metaProperty.name());
QByteArray array = ememberVarName.toLocal8Bit();
char* buffer = array.data();
QVariant set = m_object->property(buffer);
if (set.type() == QVariant::Bool)
{
b_SetEnabled = (bool &)set;
}
// qDebug() << "Member Name :" << memberVarName;
// Note: process the first char if it contains _ then the var is read only and remove the _ char
if (memberVarName.at(0) == "_") {
b_SetEnabled = false;
memberVarName.remove(0, 1);
}
// after that replace all occurance of _ with space char for display
memberVarName.replace(QString("_"), QString(" "));
if (!metaProperty.isReadable()) {
subProperty = m_readOnlyManager->addProperty(QVariant::String, memberVarName);
subProperty->setValue(QLatin1String("< Non Readable >"));
}
else if (metaProperty.isEnumType()) {
if (metaProperty.isFlagType()) {
subProperty = m_manager->addProperty(QtVariantPropertyManager::flagTypeId(), memberVarName);
QMetaEnum metaEnum = metaProperty.enumerator();
QMap<int, bool> valueMap;
QStringList flagNames;
for (int i = 0; i < metaEnum.keyCount(); i++) {
int value = metaEnum.value(i);
if (!valueMap.contains(value) && isPowerOf2(value)) {
valueMap[value] = true;
flagNames.append(QLatin1String(metaEnum.key(i)));
}
subProperty->setAttribute(QLatin1String("flagNames"), flagNames);
subProperty->setValue(flagToInt(metaEnum, metaProperty.read(m_object).toInt()));
}
}
else {
subProperty = m_manager->addProperty(QtVariantPropertyManager::enumTypeId(), memberVarName);
QMetaEnum metaEnum = metaProperty.enumerator();
QMap<int, bool> valueMap; // dont show multiple enum values which have the same values
QStringList enumNames;
for (int i = 0; i < metaEnum.keyCount(); i++) {
int value = metaEnum.value(i);
if (!valueMap.contains(value)) {
valueMap[value] = true;
enumNames.append(QLatin1String(metaEnum.key(i)));
}
}
subProperty->setAttribute(QLatin1String("enumNames"), enumNames);
subProperty->setValue(enumToInt(metaEnum, metaProperty.read(m_object).toInt()));
}
}
else if (m_manager->isPropertyTypeSupported(type)) {
if (!metaProperty.isWritable())
subProperty = m_readOnlyManager->addProperty(type, memberVarName + QLatin1String(" (Non Writable)"));
if (!metaProperty.isDesignable())
subProperty = m_readOnlyManager->addProperty(type, memberVarName + QLatin1String(" (Non Designable)"));
else
subProperty = m_manager->addProperty(type, memberVarName);
subProperty->setValue(metaProperty.read(m_object));
}
else {
subProperty = m_readOnlyManager->addProperty(QVariant::String, memberVarName);
subProperty->setValue(QLatin1String("< Unknown Type >"));
b_SetEnabled = false;
}
// Notes: QtVariantProperty *priority = variantManager->addProperty(QVariant::Int, "Priority");
if (subProperty)
subProperty->setEnabled(b_SetEnabled);
m_propertyToIndex[subProperty] = idx;
m_classToIndexToProperty[metaObject][idx] = subProperty;
if (subGroup)
classProperty->addSubProperty(subProperty);
else
m_browser->addProperty(subProperty);
}
}
else {
updateClassProperties(metaObject, false);
}
m_topLevelProperties.append(classProperty);
if (subGroup)
m_browser->addProperty(classProperty);
} // Loop i
}
示例6: addAxisSet
void QwtPlotPropertySetDialog::addAxisSet(QtProperty* parentGroup, ChartWave_qwt* plot,QwtPlot::Axis axis)
{
m_enableSet = false;
QtVariantProperty *pro = nullptr;
//QwtScaleWidget* scaleWidget = plot->axisWidget(axis);
QwtScaleDraw *scaleDraw = plot->axisScaleDraw(axis);
QwtDateScaleDraw* dateScale = dynamic_cast<QwtDateScaleDraw*>(scaleDraw);
//轴详细设置
QtProperty *childGroup = m_property_id.addGroupInGroup(m_variantManager,parentGroup
,QStringLiteral("%1轴设置").arg(axisString(axis))
,axisPropertyID(axis,0));
childGroup->setEnabled(plot->axisEnabled(axis));//在轴允许时才让设置
QwtInterval inv= plot->axisInterval(axis);
m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::PointF
,childGroup
,QStringLiteral("坐标范围")
,axisPropertyID(axis,4)
,QPointF(inv.minValue(),inv.maxValue()));
m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::String
,childGroup,QStringLiteral("标题")
,axisPropertyID(axis,1)
,m_plot->axisTitle(axis).text());
//
m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::Double
,childGroup,QStringLiteral("刻度文字角度")
,axisPropertyID(axis,5)
,scaleDraw->labelRotation());
pro = m_property_id.addVariantPropertyInGroup(m_variantManager,QtVariantPropertyManager::enumTypeId()
,childGroup
,QStringLiteral("%1轴样式").arg(axisString(axis))
,axisPropertyID(axis,2)
,0);
pro->setAttribute(QLatin1String("enumNames"),QStringList()
<<QStringLiteral("正常坐标轴")
<<QStringLiteral("时间坐标轴")
);
ScaleDraw sd = NormalScale;
sd = ((dateScale == nullptr) ? NormalScale : DateScale);
pro->setValue(int(sd));
pro = m_property_id.addVariantPropertyInGroup(m_variantManager,QtVariantPropertyManager::enumTypeId()
,childGroup
,QStringLiteral("时间格式")
,axisPropertyID(axis,3)
,int(ChartWave_qwt::hh_mm_ss));
pro->setAttribute(QLatin1String("enumNames"), QStringList()
<<QStringLiteral("h_m")
<<QStringLiteral("hh_mm")
<<QStringLiteral("h_m_s")
<<QStringLiteral("hh_mm_ss")
<<QStringLiteral("yyyy_M_d")
<<QStringLiteral("yyyy_M_d_h_m")
<<QStringLiteral("yyyy_M_d_h_m_s")
<<QStringLiteral("yyyy_MM_dd")
<<QStringLiteral("yyyy_MM_dd_hh_mm")
<<QStringLiteral("yyyy_MM_dd_hh_mm_ss")
);//在setAttribute过程中会触发onPropertyValueChanged,而onPropertyValueChanged的值是0,需要使用m_enableAxisEnableSet来抑制
pro->setValue(int(ChartWave_qwt::hh_mm_ss));
pro->setEnabled(sd == DateScale);
m_enableSet = true;
}