本文整理汇总了C++中QExtensionManager::extension方法的典型用法代码示例。如果您正苦于以下问题:C++ QExtensionManager::extension方法的具体用法?C++ QExtensionManager::extension怎么用?C++ QExtensionManager::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QExtensionManager
的用法示例。
在下文中一共展示了QExtensionManager::extension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()) {
//.........这里部分代码省略.........