本文整理汇总了C++中QtVariantProperty::propertyType方法的典型用法代码示例。如果您正苦于以下问题:C++ QtVariantProperty::propertyType方法的具体用法?C++ QtVariantProperty::propertyType怎么用?C++ QtVariantProperty::propertyType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QtVariantProperty
的用法示例。
在下文中一共展示了QtVariantProperty::propertyType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editorValueChanged
void PropertyEditorView::editorValueChanged(QtProperty *prop, QVariant value)
{
if (mChangingPropertyValue) {
return;
}
QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(prop);
int propertyType = property->propertyType(),
row = mPropertyEditor->properties().indexOf(property);
QModelIndex const &index = mModel->index(row, 1);
if (propertyType == QtVariantPropertyManager::enumTypeId()) {
QStringList const &values = mModel->enumValues(index);
int intValue = value.toInt();
if (intValue >= 0 && intValue < values.length()) {
value = values.at(intValue);
}
}
value = QVariant(value.toString());
QVariant const oldValue = mModel->data(index);
// TODO: edit included Qt Property Browser framework or inherit new browser
// from it and create propertyCommited() and propertyCancelled() signal
qReal::commands::ChangePropertyCommand *changeCommand =
new qReal::commands::ChangePropertyCommand(mModel, index, oldValue, value);
mController->execute(changeCommand);
}
示例2: dataChanged
void PropertyEditorView::dataChanged(const QModelIndex &, const QModelIndex &)
{
for (int i = 0, rows = mModel->rowCount(QModelIndex()); i < rows; ++i) {
QModelIndex const &valueIndex = mModel->index(i, 1);
QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(mPropertyEditor->properties().at(i));
QVariant value = valueIndex.data();
if (property) {
if (property->propertyType() == QtVariantPropertyManager::enumTypeId()) {
value = enumPropertyIndexOf(valueIndex, value.toString());
}
setPropertyValue(property, value);
property->setToolTip(value.toString());
}
}
}
示例3: dataChanged
void PropertyEditorView::dataChanged(const QModelIndex &, const QModelIndex &)
{
for (int i = 0, rows = mModel->rowCount(QModelIndex()); i < rows; ++i) {
const QModelIndex &valueIndex = mModel->index(i, 1);
QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(mPropertyEditor->properties().at(i));
QVariant value = valueIndex.data();
if (property) {
if (property->propertyType() == QtVariantPropertyManager::enumTypeId()) {
const int index = enumPropertyIndexOf(valueIndex, value.toString());
if (!mModel->enumEditable(valueIndex) || index >= 0) {
value = index;
}
}
setPropertyValue(property, value);
const QString description = propertyDescription(i);
const QString tooltip = description.isEmpty() ? value.toString() : description;
property->setToolTip(tooltip);
}
}
}
示例4: editorValueChanged
void PropertyEditorView::editorValueChanged(QtProperty *prop, QVariant value)
{
if (mChangingPropertyValue) {
return;
}
QtVariantProperty *property = dynamic_cast<QtVariantProperty*>(prop);
int propertyType = property->propertyType();
int row = mPropertyEditor->properties().indexOf(property);
const QModelIndex &index = mModel->index(row, 1);
if (propertyType == QtVariantPropertyManager::enumTypeId()) {
QList<QPair<QString, QString>> const values = mModel->enumValues(index);
if (mModel->enumEditable(index)) {
for (const auto &keyValue : values) {
if (keyValue.second == value) {
value = keyValue.first;
}
}
} else {
const int intValue = value.toInt();
if (intValue >= 0 && intValue < values.length()) {
value = values.at(intValue).first;
}
}
}
value = QVariant(value.toString());
const Id id = mModel->idByIndex(index);
const QString propertyName = mModel->propertyName(index);
// TODO: edit included Qt Property Browser framework or inherit new browser
// from it and create propertyCommited() and propertyCancelled() signal
qReal::commands::ChangePropertyCommand *changeCommand =
new qReal::commands::ChangePropertyCommand(mLogicalModelAssistApi, propertyName, id, value);
mController->execute(changeCommand);
}
示例5: setObject
void PropertyEditor::setObject(QObject *object)
{
QDesignerFormWindowInterface *oldFormWindow = QDesignerFormWindowInterface::findFormWindow(m_object);
// In the first setObject() call following the addition of a dynamic property, focus and edit it.
const bool editNewDynamicProperty = object != 0 && m_object == object && !m_recentlyAddedDynamicProperty.isEmpty();
m_object = object;
m_propertyManager->setObject(object);
QDesignerFormWindowInterface *formWindow = QDesignerFormWindowInterface::findFormWindow(m_object);
FormWindowBase *fwb = qobject_cast<FormWindowBase *>(formWindow);
m_treeFactory->setFormWindowBase(fwb);
m_groupFactory->setFormWindowBase(fwb);
storeExpansionState();
UpdateBlocker ub(this);
updateToolBarLabel();
QMap<QString, QtVariantProperty *> toRemove = m_nameToProperty;
const QDesignerDynamicPropertySheetExtension *dynamicSheet =
qt_extension<QDesignerDynamicPropertySheetExtension*>(m_core->extensionManager(), m_object);
const QDesignerPropertySheet *sheet = qobject_cast<QDesignerPropertySheet*>(m_core->extensionManager()->extension(m_object, Q_TYPEID(QDesignerPropertySheetExtension)));
// Optimizization: Instead of rebuilding the complete list every time, compile a list of properties to remove,
// remove them, traverse the sheet, in case property exists just set a value, otherwise - create it.
QExtensionManager *m = m_core->extensionManager();
m_propertySheet = qobject_cast<QDesignerPropertySheetExtension*>(m->extension(object, Q_TYPEID(QDesignerPropertySheetExtension)));
if (m_propertySheet) {
const int propertyCount = m_propertySheet->count();
for (int i = 0; i < propertyCount; ++i) {
if (!m_propertySheet->isVisible(i))
continue;
const QString propertyName = m_propertySheet->propertyName(i);
if (m_propertySheet->indexOf(propertyName) != i)
continue;
const QString groupName = m_propertySheet->propertyGroup(i);
const QMap<QString, QtVariantProperty *>::const_iterator rit = toRemove.constFind(propertyName);
if (rit != toRemove.constEnd()) {
QtVariantProperty *property = rit.value();
if (m_propertyToGroup.value(property) == groupName && toBrowserType(m_propertySheet->property(i), propertyName) == property->propertyType())
toRemove.remove(propertyName);
}
}
}
QMapIterator<QString, QtVariantProperty *> itRemove(toRemove);
while (itRemove.hasNext()) {
itRemove.next();
QtVariantProperty *property = itRemove.value();
m_nameToProperty.remove(itRemove.key());
m_propertyToGroup.remove(property);
delete property;
}
if (oldFormWindow != formWindow)
reloadResourceProperties();
bool isMainContainer = false;
if (QWidget *widget = qobject_cast<QWidget*>(object)) {
if (QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(widget)) {
isMainContainer = (fw->mainContainer() == widget);
}
}
m_groups.clear();
if (m_propertySheet) {
QtProperty *lastProperty = 0;
QtProperty *lastGroup = 0;
const int propertyCount = m_propertySheet->count();
for (int i = 0; i < propertyCount; ++i) {
if (!m_propertySheet->isVisible(i))
continue;
const QString propertyName = m_propertySheet->propertyName(i);
if (m_propertySheet->indexOf(propertyName) != i)
continue;
const QVariant value = m_propertySheet->property(i);
const int type = toBrowserType(value, propertyName);
QtVariantProperty *property = m_nameToProperty.value(propertyName, 0);
bool newProperty = property == 0;
if (newProperty) {
property = m_propertyManager->addProperty(type, propertyName);
if (property) {
newProperty = true;
if (type == DesignerPropertyManager::enumTypeId()) {
const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(value);
QStringList names;
QStringListIterator it(e.metaEnum.keys());
while (it.hasNext())
names.append(it.next());
m_updatingBrowser = true;
property->setAttribute(m_strings.m_enumNamesAttribute, names);
m_updatingBrowser = false;
} else if (type == DesignerPropertyManager::designerFlagTypeId()) {
//.........这里部分代码省略.........