赞
踩
属性表是vs2003时引入的的新控件,用于流量和设置大量的信息,现在,很多软件上都能看到它的身影,如vs,Qt Creator等IDE的详细设置里都离不开属性表。
QtBoolPropertyManager
QtColorPropertyManager
QtDatePropertyManager
QtDateTimePropertyManager
QtDoublePropertyManager
QtEnumPropertyManager
QtFlagPropertyManager
QtFontPropertyManager
QtGroupPropertyManager
QtIntPropertyManager
QtPointPropertyManager
QtRectPropertyManager
QtSizePropertyManager
QtSizePolicyPropertyManager
QtStringPropertyManager
QtTimePropertyManager
QtVariantPropertyManager
QtVariantPropertyManager*m_pVarManager;
- m_pVarManager =newQtVariantPropertyManager(ui->propertyTree);
- QtVariantProperty *item =m_pVarManager->addProperty(QVariant::Int, QStringLiteral("整形数据:"));
- item->setValue(101);
- ui->propertyTree->addProperty(item);
- item =m_pVarManager->addProperty(QVariant::Bool, QStringLiteral("布尔型数据:"));
- item->setValue(true);
- ui->propertyTree->addProperty(item);
- item =m_pVarManager->addProperty(QVariant::Double, QStringLiteral("浮点数据:"));
- item->setValue(3.1415926);
- ui->propertyTree->addProperty(item);
- item =m_pVarManager->addProperty(QVariant::String, QStringLiteral("字符串数据:"));
- ui->propertyTree->addProperty(item);
- item->setValue(QStringLiteral("尘中远"));
- m_pVarManager =newQtVariantPropertyManager(ui->propertyTree);
- QtProperty *groupItem =m_pVarManager->addProperty(QtVariantPropertyManager::groupTypeId(),QStringLiteral("组1"));
- QtVariantProperty *item =m_pVarManager->addProperty(QVariant::Int, QStringLiteral("整形数据:"));
- item->setValue(101);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::Bool, QStringLiteral("布尔型数据:"));
- item->setValue(true);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::Double, QStringLiteral("浮点数据:"));
- item->setValue(3.1415926);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::String, QStringLiteral("字符串数据:"));
- groupItem->addSubProperty(item);
- item->setValue(QStringLiteral("尘中远"));
- ui->propertyTree->addProperty(groupItem);
- QtVariantPropertyManager*m_pVarManager;
- QtVariantEditorFactory*m_pVarFactory;
- m_pVarManager =newQtVariantPropertyManager(ui->propertyTree);
- m_pVarFactory =newQtVariantEditorFactory(ui->propertyTree);
- QtProperty *groupItem =m_pVarManager->addProperty(QtVariantPropertyManager::groupTypeId(),QStringLiteral("组1"));
- QtVariantProperty *item =m_pVarManager->addProperty(QVariant::Int, QStringLiteral("整形数据:"));
- item->setValue(101);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::Bool, QStringLiteral("布尔型数据:"));
- item->setValue(true);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::Double, QStringLiteral("浮点数据:"));
- item->setValue(3.1415926);
- groupItem->addSubProperty(item);
- item =m_pVarManager->addProperty(QVariant::String, QStringLiteral("字符串数据:"));
- groupItem->addSubProperty(item);
- item->setValue(QStringLiteral("尘中远"));
- ui->propertyTree->addProperty(groupItem);
- ui->propertyTree->setFactoryForManager(m_pVarManager,m_pVarFactory);
h文件
- QMap<QtProperty*,QString>m_property_dic;
- QtVariantPropertyManager*m_pVarManager;
- QtVariantEditorFactory*m_pVarFactory;
cpp
- XXXClass::XXXClass(QWidget *parent)
- :QMainWindow(parent),ui(newUi::XXXClass) {
- m_pVarManager =newQtVariantPropertyManager(ui->propertyTree);
- m_pVarFactory =newQtVariantEditorFactory(ui->propertyTree);
- connect(m_pVarManager,&QtVariantPropertyManager::valueChanged,this,&XXXClass::variantPropertyValueChanged);
- ui->propertyTree->setFactoryForManager(m_pVarManager,m_pVarFactory);
- QtVariantProperty *item =m_pVarManager->addProperty(QVariant::Int, QStringLiteral("参数1"));
- item->setValue(1);
- ui->propertyTree->addProperty(item);
- m_property_dic[item] =QStringLiteral("参数1");
- item =m_pVarManager->addProperty(QVariant::Double, QStringLiteral("参数2"));
- item->setValue(2);
- ui->propertyTree->addProperty(item);
- m_property_dic[item] =QStringLiteral("参数2");
- item =m_pVarManager->addProperty(QVariant::String, QStringLiteral("参数3"));
- item->setValue(QStringLiteral("czy"));
- ui->propertyTree->addProperty(item);
- m_property_dic[item] =QStringLiteral("参数3");
- item =m_pVarManager->addProperty(QVariant::Bool, QStringLiteral("参数4"));
- item->setValue(true);
- ui->propertyTree->addProperty(item);
- m_property_dic[item] =QStringLiteral("参数4");
- }
-
- voidXXXClass::variantPropertyValueChanged(QtProperty *property, constQVariant &value)
- {
- QString s =m_property_dic[property];
- qDebug()<<s<<":"<<value;
- }
下载地址更新:http://download.csdn.net/detail/czyt1988/9516757 无需积分
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。