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


C++ QMetaEnum类代码示例

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


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

示例1: qtscript_construct_QAbstractSpinBox_CorrectionMode

static QScriptValue qtscript_construct_QAbstractSpinBox_CorrectionMode(QScriptContext *context, QScriptEngine *engine)
{
    int arg = context->argument(0).toInt32();
    const QMetaObject *meta = qtscript_QAbstractSpinBox_metaObject();
    int idx = meta->indexOfEnumerator("CorrectionMode");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    if (menum.valueToKey(arg) != 0)
        return qScriptValueFromValue(engine,  static_cast<QAbstractSpinBox::CorrectionMode>(arg));
    return context->throwError(QString::fromLatin1("CorrectionMode(): invalid enum value (%0)").arg(arg));
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:11,代码来源:qtscript_QAbstractSpinBox.cpp

示例2: qtscript_construct_QFontDialog_FontDialogOption

static QScriptValue qtscript_construct_QFontDialog_FontDialogOption(QScriptContext *context, QScriptEngine *engine)
{
    int arg = context->argument(0).toInt32();
    const QMetaObject *meta = qtscript_QFontDialog_metaObject();
    int idx = meta->indexOfEnumerator("FontDialogOption");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    if (menum.valueToKey(arg) != 0)
        return qScriptValueFromValue(engine,  static_cast<QFontDialog::FontDialogOption>(arg));
    return context->throwError(QString::fromLatin1("FontDialogOption(): invalid enum value (%0)").arg(arg));
}
开发者ID:Mistobaan,项目名称:MuseScore,代码行数:11,代码来源:qtscript_QFontDialog.cpp

示例3: rowCount

int ObjectEnumModel::rowCount(const QModelIndex &parent) const
{
  if (!parent.isValid()) {
    return SuperClass::rowCount(parent);
  }
  if (parent.parent().isValid()) {
    return 0;
  }
  const QMetaEnum e = m_object.data()->metaObject()->enumerator(parent.row());
  return e.keyCount();
}
开发者ID:frankosterfeld,项目名称:GammaRay,代码行数:11,代码来源:objectenummodel.cpp

示例4: indexForFormat

int BookStyleItem::indexForFormat(Format::Type type)
{
    static const int foregroundsIndex = staticMetaObject.indexOfEnumerator("ForegroundColorType");
    static const QMetaEnum foregrounds = staticMetaObject.enumerator(foregroundsIndex);

    static const int typesIndex = Format::staticMetaObject.indexOfEnumerator("Type");
    static const QMetaEnum types = Format::staticMetaObject.enumerator(typesIndex);

    const char *key = types.valueToKey(type);
    return foregrounds.keyToValue(key);
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:11,代码来源:bookstyle.cpp

示例5: qtscript_construct_QComboBox_SizeAdjustPolicy

static QScriptValue qtscript_construct_QComboBox_SizeAdjustPolicy(QScriptContext *context, QScriptEngine *engine)
{
    int arg = context->argument(0).toInt32();
    const QMetaObject *meta = qtscript_QComboBox_metaObject();
    int idx = meta->indexOfEnumerator("SizeAdjustPolicy");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    if (menum.valueToKey(arg) != 0)
        return qScriptValueFromValue(engine,  static_cast<QComboBox::SizeAdjustPolicy>(arg));
    return context->throwError(QString::fromLatin1("SizeAdjustPolicy(): invalid enum value (%0)").arg(arg));
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:11,代码来源:qtscript_QComboBox.cpp

示例6: mp

QStringList Country::getCountryNames() {
    if (sCountryNames.isEmpty()) {
        Country cc;
        QMetaProperty mp(cc.metaProperty("val"));
        QMetaEnum qmen = mp.enumerator();
        for (int i=0; i<qmen.keyCount(); ++i) {
            sCountryNames += qmen.valueToKey(i);
        }
    }
    return sCountryNames;
}
开发者ID:jabouzi,项目名称:qt,代码行数:11,代码来源:country.cpp

示例7: rulesTypeFromString

static core::WorldRules::Type rulesTypeFromString(const char* str)
{
    const QMetaEnum metaEnum{QMetaEnum::fromType<core::WorldRules::Type>()};
    bool ok{true};
    auto e = metaEnum.keyToValue(str, &ok);

    if (!ok)
        throw utils::ValueError("Failed to unserialize RulesType");

    return static_cast<core::WorldRules::Type>(e);
}
开发者ID:denesb,项目名称:warmonger,代码行数:11,代码来源:wtest_rules_bindings.cpp

示例8: QAbstractTableModel

PaletteModel::PaletteModel(QObject *parent)  : 
    QAbstractTableModel(parent),
    m_compute(true)
{
    const QMetaObject *meta = metaObject();
    const int index = meta->indexOfProperty("colorRole");
    const QMetaProperty p = meta->property(index);
    const QMetaEnum e = p.enumerator();
    for (int r = QPalette::WindowText; r < QPalette::NColorRoles; r++) {
        m_roleNames[static_cast<QPalette::ColorRole>(r)] = QLatin1String(e.key(r));
    }
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:12,代码来源:paletteeditor.cpp

示例9: settingsValueChanged

void Terrain3D::loadUserSettings()
{
    const QMetaObject &mo = Settings::staticMetaObject;
    const QMetaEnum me = mo.enumerator(mo.indexOfEnumerator("Key"));

    //loop through every Settings::Key and tell ourself that a value has
    //changed to effectively load the value
    for (int i=0; i<me.keyCount(); i++)
    {
        Settings::Key key = static_cast<Settings::Key>(me.value(i));
        settingsValueChanged(key, mMainSettings->value(key));
    }
}
开发者ID:DanWatkins,项目名称:Terrain3D,代码行数:13,代码来源:Terrain3D.cpp

示例10: metaData

QVariant ObjectEnumModel::metaData(const QModelIndex &index,
                               const QMetaEnum &enumerator, int role) const
{
  if (role == Qt::DisplayRole) {
    if (index.column() == 0) {
      return QString::fromLatin1(enumerator.name());
    }
    if (index.column() == 1) {
      return tr("%n element(s)", "", enumerator.keyCount());
    }
  }
  return QVariant();
}
开发者ID:aleixpol,项目名称:GammaRay,代码行数:13,代码来源:objectenummodel.cpp

示例11: pix

void Window::createCurveIcons()
{
    QPixmap pix(m_iconSize);
    QPainter painter(&pix);
    QLinearGradient gradient(0,0, 0, m_iconSize.height());
    gradient.setColorAt(0.0, QColor(240, 240, 240));
    gradient.setColorAt(1.0, QColor(224, 224, 224));
    QBrush brush(gradient);
    const QMetaObject &mo = QEasingCurve::staticMetaObject;
    QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type"));
    // Skip QEasingCurve::Custom
    for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) {
        painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush);
        QEasingCurve curve((QEasingCurve::Type)i);
        painter.setPen(QColor(0, 0, 255, 64));
        qreal xAxis = m_iconSize.height()/1.5;
        qreal yAxis = m_iconSize.width()/3;
        painter.drawLine(0, xAxis, m_iconSize.width(),  xAxis);
        painter.drawLine(yAxis, 0, yAxis, m_iconSize.height());

        qreal curveScale = m_iconSize.height()/2;

        painter.setPen(Qt::NoPen);

        // start point
        painter.setBrush(Qt::red);
        QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0));
        painter.drawRect(start.x() - 1, start.y() - 1, 3, 3);

        // end point
        painter.setBrush(Qt::blue);
        QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1));
        painter.drawRect(end.x() - 1, end.y() - 1, 3, 3);

        QPainterPath curvePath;
        curvePath.moveTo(start);
        for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) {
            QPoint to;
            to.setX(yAxis + curveScale * t);
            to.setY(xAxis - curveScale * curve.valueForProgress(t));
            curvePath.lineTo(to);
        }
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.strokePath(curvePath, QColor(32, 32, 32));
        painter.setRenderHint(QPainter::Antialiasing, false);
        QListWidgetItem *item = new QListWidgetItem;
        item->setIcon(QIcon(pix));
        item->setText(metaEnum.key(i));
        m_ui.easingCurvePicker->addItem(item);
    }
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:51,代码来源:window.cpp

示例12: QString

void GCF::Components::EnumEditorCreator::initialize(QWidget* editor, QMetaEnum enumStruct)
{
    QComboBox* combo = qobject_cast<QComboBox*>(editor);
    if(!combo)
        return;

    for(int i=enumStruct.keyCount()-1; i>=0; i--)
    {
        QString key = QString("%1").arg(enumStruct.key(i));
        int value = enumStruct.value(i);
        combo->insertItem(0, key);
        combo->setItemData(0, value);
    }
}
开发者ID:banduladh,项目名称:levelfour,代码行数:14,代码来源:ValueEditorCreators.cpp

示例13: enumToInt

int ObjectControllerPrivate::enumToInt(const QMetaEnum &metaEnum, int enumValue) const
{
    QMap<int, int> valueMap; // dont show multiple enum values which have the same values
    int pos = 0;
    for (int i = 0; i < metaEnum.keyCount(); i++) {
        int value = metaEnum.value(i);
        if (!valueMap.contains(value)) {
            if (value == enumValue)
                return pos;
            valueMap[value] = pos++;
        }
    }
    return -1;
}
开发者ID:Elv13,项目名称:Kimberlite,代码行数:14,代码来源:objectcontroller.cpp

示例14: metaObject

void SimpleLoggerRoutingInfo::setRouting(MessageRoutings messageRoutings, bool state)
{
  const QMetaObject* metaObj = metaObject();
  QMetaEnum metaEnum = metaObj->enumerator(metaObj->indexOfEnumerator("MessageRouting"));

  for (int i=0; i<metaEnum.keyCount(); ++i)
  {
    MessageRouting messageRouting = static_cast<MessageRouting>(metaEnum.value(i));
    if ((messageRoutings & messageRouting) == messageRouting)
    {
      m_routing->insert(messageRouting, state);
    }
  }
}
开发者ID:pitonyak,项目名称:LinkBackADP,代码行数:14,代码来源:simpleloggerroutinginfo.cpp

示例15: QObject

QQnxButtonEventNotifier::QQnxButtonEventNotifier(QObject *parent)
    : QObject(parent),
      m_fd(-1),
      m_readNotifier(0)
{
    // Set initial state of buttons to ButtonUp and
    // fetch the new button ids
    int enumeratorIndex = QQnxButtonEventNotifier::staticMetaObject.indexOfEnumerator(QByteArrayLiteral("ButtonId"));
    QMetaEnum enumerator = QQnxButtonEventNotifier::staticMetaObject.enumerator(enumeratorIndex);
    for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) {
        m_buttonKeys.append(enumerator.valueToKey(buttonId));
        m_state[buttonId] = ButtonUp;
    }
}
开发者ID:crobertd,项目名称:qtbase,代码行数:14,代码来源:qqnxbuttoneventnotifier.cpp


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