代码如下:
variantManagerAction = new QtVariantPropertyManager(); topPropertyAction = variantManagerAction->addProperty(QtVariantPropertyManager::groupTypeId(), tr("动作属性")); item = variantManagerModule->addProperty(QVariant::String, tr("名称")); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QtVariantPropertyManager::enumTypeId(), tr("主动作类型")); actionList << "信号动作" <<"变量动作"<<"信号和变量组合动作"<<"定时动作"<<"始终动作"<<"刀具寿命动作"; item->setAttribute(QLatin1String("enumNames"), actionList); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QVariant::String, tr("信号名")); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QtVariantPropertyManager::enumTypeId(), tr("条件操作符")); //QStringList enumOpt; operList<<">"<<"<"<<"="<<"<>"; item->setAttribute(QLatin1String("enumNames"), operList); item->setValue(2); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QVariant::String, tr("信号值")); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QtVariantPropertyManager::enumTypeId(), tr("附加条件操作符")); //QStringList addMove; exterList<< "" <<"与"<<"或"<<"非"; item->setAttribute(QLatin1String("enumNames"), exterList); item->setValue(0); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QVariant::Int, tr("动作执行次数")); item->setValue(0); topPropertyAction->addSubProperty(item); item = variantManagerAction->addProperty(QtVariantPropertyManager::enumTypeId(), tr("更新方式")); QStringList updateName; updateName<<"绝对动作"<<"相对动作"; item->setAttribute(QLatin1String("enumNames"), updateName); item->setValue(1); topPropertyAction->addSubProperty(item); QtVariantEditorFactory *variantFactoryAction = new QtVariantEditorFactory(); ui.propertyAction->setFactoryForManager(variantManagerAction, variantFactoryAction); ui.propertyAction->addProperty(topPropertyAction); 出来编辑菜单后 我可以用鼠标去选中 结果那一项变蓝 但不知道用程序代码如何去选中了