当前位置: 首页>>代码示例>>C++>>正文


C++ ImageItem::metaObject方法代码示例

本文整理汇总了C++中ImageItem::metaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem::metaObject方法的具体用法?C++ ImageItem::metaObject怎么用?C++ ImageItem::metaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageItem的用法示例。


在下文中一共展示了ImageItem::metaObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadGeometry

void StitcherWorkspace::loadGeometry() {
    /*
       This is a prefix to distinguish Hawk Geometry properties from the
       normal widget properties
    */
    const QString tag("HawkGeometry_");
    QList<QGraphicsItem *> ii  = _stitcherView->items();
    QMap<QString,ImageItem *> sortMap;
    for(int i = 0; i<ii.size(); i++) {
        if(ImageItem * imageItem = qgraphicsitem_cast<ImageItem *>(ii[i])) {
            if(imageItem->isVisible()) {
                sortMap.insert(imageItem->identifier(),imageItem);
            }
        }
    }
    QList<ImageItem *>sortedItems = sortMap.values();
    QStandardItemModel * model = qobject_cast<QStandardItemModel *>(geometryTree->model());
    model->clear();
    model->setHorizontalHeaderLabels(QStringList() << "Parameter" << "Value" << "Locked");

    for(int i = 0; i<sortedItems.size(); i++) {
        ImageItem * imageItem = sortedItems[i];
        const QMetaObject *metaobject =  imageItem->metaObject();
        int count = metaobject->propertyCount();
        QStandardItem * itemName = new QStandardItem(imageItem->identifier());
        QStandardItem * itemValue = new QStandardItem();
        QStandardItem * itemLocked = new QStandardItem();
        itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
        QStandardItem *parentItem = model->invisibleRootItem();
        itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
        itemValue->setFlags(itemValue->flags() & ~Qt::ItemIsEditable);
        if(model->findItems(itemName->text()).empty()) {
            parentItem->appendRow(QList<QStandardItem *>() << itemName <<  itemValue << itemLocked);
            parentItem = itemName;
        } else {
            parentItem = model->findItems(itemName->text()).first();
        }
        for (int j=0; j<count; ++j) {
            QMetaProperty metaproperty = metaobject->property(j);
            const char *name = metaproperty.name();
            if(!QString(name).startsWith(tag)) {
                continue;
            }
            QVariant var =  imageItem->property(name);
            Qt::ItemFlags itemValueFlags = Qt::ItemIsSelectable|Qt::ItemIsEnabled;
            if(metaproperty.isWritable()) {
                itemValueFlags |= Qt::ItemIsEditable;
            }
            if(var.type() == QVariant::Double) {
                double value = var.toDouble();
                if(QString(name).endsWith("_theta") || QString(name).endsWith("_alpha")) {
                    /* convert to degrees */
                    value *= 180/M_PI;
                }
                if(QString(name).endsWith("_dy")) {
                    /* swap axis */
                    value = -value;
                }
                QStandardItem * itemName = new QStandardItem(_stitcherView->propertyNameToDisplayName(name,tag));
                QStandardItem * itemValue = new QStandardItem(QString("%0").arg(value));
                itemValue->setData(value,Qt::UserRole + 1);
                itemValue->setData(QString(name),Qt::UserRole + 2);
                itemValue->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
                itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
                itemValue->setFlags(itemValueFlags);
                QStandardItem * itemLocked = new QStandardItem();
                itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
                /* check for lock property */
                QString lockedPropertyName = name + QString("_locked");
                if(imageItem->property(lockedPropertyName.toAscii().data()).isValid()) {
                    bool locked = imageItem->property(lockedPropertyName.toAscii().data()).toBool();
                    itemLocked->setCheckable(true);
                    itemLocked->setData(locked,Qt::UserRole + 1);
                    itemLocked->setData(QString(lockedPropertyName),Qt::UserRole + 2);
                    itemLocked->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
                    if(locked) {
                        itemLocked->setCheckState(Qt::Checked);
                        itemValue->setEnabled(false);
                    }
                }
                /* Temporarily disable Dz and Alpha */
                if(itemName->text() == "Dz" ||
                        itemName->text() == "Alpha") {
                    itemLocked->setCheckState(Qt::Checked);
                    itemName->setEnabled(false);
                    itemValue->setEnabled(false);
                    itemLocked->setEnabled(false);
                    itemName->setToolTip("Currently disabled");
                    itemValue->setToolTip("Currently disabled");
                    itemLocked->setToolTip("Currently disabled");
                }
                parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked);
            }
        }
    }
    geometryTree->expandAll();
    geometryTree->resizeColumnToContents(0);
    geometryTree->sortByColumn(0,Qt::AscendingOrder);
}
开发者ID:ng110,项目名称:hawk,代码行数:99,代码来源:stitcherworkspace.cpp


注:本文中的ImageItem::metaObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。