本文整理汇总了C++中QMetaEnum::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaEnum::value方法的具体用法?C++ QMetaEnum::value怎么用?C++ QMetaEnum::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaEnum
的用法示例。
在下文中一共展示了QMetaEnum::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AbstractParam
ParamEnum::ParamEnum( QObject *parent, const char* name, int value, const QString& e, int *ptr )
: AbstractParam(parent, name, QVariant::Int)
{
m_ptr = ptr;
QStringList L = e.split('|', QString::SkipEmptyParts);
if (!L.isEmpty()) {
for (int i = 0; i < L.size(); ++i) {
m_keys.append(L[i]);
m_values.append(i);
}
} else {
QObject *p = parent;
while (p) {
const QMetaObject *mo = p->metaObject();
int index = mo->indexOfEnumerator(e.toLatin1().data());
if (index >= 0) {
const QMetaEnum me = mo->enumerator(index);
for (int i = 0; i < me.keyCount(); ++i) {
m_keys.append(me.key(i));
m_values.append(me.value(i));
}
break;
}
p = p->parent();
}
}
m_value = m_defaultValue = value;
if (m_ptr) *m_ptr = m_value;
}
示例2: REPLCompletable
// private:
Phantom::Phantom(QObject *parent)
: REPLCompletable(parent)
, m_terminated(false)
, m_returnValue(0)
, m_filesystem(0)
, m_system(0)
{
// Skip the first argument, i.e. the application executable (phantomjs).
QStringList args = QApplication::arguments();
args.removeFirst();
// Prepare the configuration object based on the command line arguments.
// Because this object will be used by other classes, it needs to be ready ASAP.
m_config.init(&args);
// initialize key map
QMetaEnum keys = staticQtMetaObject.enumerator( staticQtMetaObject.indexOfEnumerator("Key") );
for(int i = 0; i < keys.keyCount(); ++i) {
QString name = keys.key(i);
if (name.startsWith("Key_")) {
name.remove(0, 4);
}
m_keyMap[name] = keys.value(i);
}
}
示例3: SIGNAL
SignalData::SignalData()
{
qDebug() << "SignalData ctor" << this;
connect(&mSampler, SIGNAL(dataArrived()), SLOT(fetchSamples()));
connect(&mSampler, SIGNAL(started()), this, SIGNAL(started()));
connect(&mSampler, SIGNAL(finished()), this, SIGNAL(finished()));
connect(&mSampler, SIGNAL(terminated()), this, SIGNAL(finished()));
connect(&mSampler, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
const QMetaObject metaObject = Sample::staticMetaObject;
const QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Marker"));
for (int i = 0; i < metaEnum.keyCount(); i++) {
mSamples.insert((Sample::Marker)metaEnum.value(i), QVector<Sample>());
mBoundingRects.insert((Sample::Marker)metaEnum.value(i), QRectF());
}
}
示例4:
QDebug operator <<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
{
QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
debug.nospace() << "PluginTypes(";
bool needSeparator = false;
int key;
for (int i = 0; i < e.keyCount(); ++i)
{
key = e.value(i);
if (flags.testFlag((SnorePlugin::PluginType)key))
{
if (needSeparator)
{
debug.nospace() << '|';
}
else
{
needSeparator = true;
}
debug.nospace() << e.valueToKey(key);
}
}
debug << ')';
return debug.space();
}
示例5: stateChanged
void GPhotoExposureControl::stateChanged(QCamera::State state)
{
if (m_state != state) {
if (m_state == QCamera::UnloadedState && state == QCamera::LoadedState) {
m_state = state;
QMetaEnum parameter = metaObject()->enumerator(metaObject()->indexOfEnumerator("ExposureParameter"));
for (int i = 0; i < parameter.keyCount(); ++i) {
ExposureParameter p = ExposureParameter(parameter.value(i));
if (isParameterSupported(p)) {
// Set all parameters requested on start to session object
if (m_requestedValues.contains(p))
setValue(p, m_requestedValues.value(p));
// or just notify frontend that it's allowed to get the parameter values from backend
else
emit actualValueChanged(p);
}
}
} else {
m_state = state;
}
}
}
示例6: genLineEnding
void MainWindow::genLineEnding()
{
resetPlot();
QMetaEnum endingStyleEnum = QCPLineEnding::staticMetaObject.enumerator(QCPLineEnding::staticMetaObject.indexOfEnumerator("EndingStyle"));
double offset = -0.2;
double step = 1.4/((double)endingStyleEnum.keyCount()-1);
for (int i=0; i<endingStyleEnum.keyCount(); ++i)
{
QCPLineEnding ending(static_cast<QCPLineEnding::EndingStyle>(endingStyleEnum.value(i)));
QString endingName(endingStyleEnum.key(i));
if (ending.style() == QCPLineEnding::esSkewedBar)
ending.setInverted(true);
QCPItemLine *line = new QCPItemLine(customPlot);
line->setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap));
customPlot->addItem(line);
line->start->setCoords(offset+i*step-0.1, -0.2);
line->end->setCoords(offset+i*step, 0.5);
line->setHead(ending);
QCPItemText *text = new QCPItemText(customPlot);
customPlot->addItem(text);
text->position->setParentAnchor(line->end);
text->position->setCoords(8, -15-(i%2)*15);
text->setFont(QFont(font().family(), 8));
text->setText(endingName);
}
customPlot->savePng(dir.filePath("QCPLineEnding.png"), 500, 100);
}
示例7: flagsToString
QString flagsToString(const QMetaEnum &aMetaEnum, const int &aValue)
{
QString res="[";
for (int i=0; i<aMetaEnum.keyCount(); ++i)
{
int aFlag=aMetaEnum.value(i);
if (((aValue & aFlag)==aFlag) && (aFlag!=0 || aValue==0))
{
bool good=true;
while (aFlag)
{
if (aFlag & 1)
{
good=(aFlag==1);
break;
}
aFlag>>=1;
}
if (good)
{
if (res.length()>1)
{
res.append(", ");
}
res.append(QString::fromLatin1(aMetaEnum.key(i)));
}
}
}
示例8: copyEnumsToProperties
void copyEnumsToProperties(QObject* object) {
const QMetaObject* meta = object->metaObject();
for (int i = 0; i < meta->enumeratorCount(); ++i) {
QMetaEnum metaenum = meta->enumerator(i);
for (int j = 0; j < metaenum.keyCount(); ++j) {
object->setProperty(metaenum.key(j), metaenum.value(j));
}
}
}
示例9: QComboBox
QWidget *MoveTypeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &/* index */) const
{
QComboBox *editor = new QComboBox(parent);
QMetaEnum moveInput = KeyBind::staticMetaObject.enumerator( KeyBind::staticMetaObject.indexOfEnumerator("MoveInputs") );
for(int i=0; i<moveInput.keyCount(); ++i) {
editor->addItem(moveInput.key(i),moveInput.value(i));
}
return editor;
}
示例10: if
QString QObjectWriter::
toString(const QVariant& val, const QMetaProperty& mprop) const {
QString result;
QVariant::Type t = mprop.type();
if (t == QVariant::Time) {
QTime t = qVariantValue<QTime>(val);
if (t.hour() > 0) {
return t.toString("hh:mm:ss");
}
else {
return t.toString("m:ss");
}
}
if (mprop.isEnumType()) {
int value = val.toInt();
QMetaEnum menum = mprop.enumerator();
if (mprop.isFlagType()) {
QStringList selectedFlags;
int kc = menum.keyCount();
for (int j=0; j<kc; ++j) {
if (menum.value(j) == 0) continue;
if ((value & menum.value(j)) == menum.value(j)) {
selectedFlags << menum.key(j);
}
}
result = selectedFlags.join("|") + QString(" (%1)").arg(val.toInt());
}
else result = QString("%1 (%2)").arg(menum.valueToKey(value)).arg(val.toInt());
return result;
}
if (m_map.contains(t)) {
VariantWriter* vw = m_map[t];
result = vw->toString(val, mprop);
}
else if (m_vwriter != 0 && result == QString())
result = m_vwriter->toString(val, mprop);
if (result == QString())
result = Qt::escape(val.toString());
else
result = Qt::escape(result);
return result;
}
示例11: 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));
}
}
示例12: QObject
SimpleLoggerRoutingInfo::SimpleLoggerRoutingInfo(QObject *parent) :
QObject(parent), m_levels(nullptr), m_routing(nullptr), m_locationRegExp(nullptr), m_messageRegExp(nullptr),
m_locationRegExpPatternSyntax(QRegExp::RegExp2), m_messageRegExpPatternSyntax(QRegExp::RegExp2),
m_locRegExpCaseSensitivity(Qt::CaseInsensitive), m_messageRegExpCaseSensitivity(Qt::CaseInsensitive),
m_enabled(true)
{
const QMetaObject* metaObj = metaObject();
QMetaEnum metaEnum = metaObj->enumerator(metaObj->indexOfEnumerator("MessageCategory"));
m_levels = new QMap<MessageCategory, int>();
for (int i=0; i<metaEnum.keyCount(); ++i)
{
m_levels->insert(static_cast<MessageCategory>(metaEnum.value(i)), 0);
}
metaEnum = metaObj->enumerator(metaObj->indexOfEnumerator("MessageRouting"));
m_routing = new QMap<MessageRouting, bool>();
for (int i=0; i<metaEnum.keyCount(); ++i)
{
m_routing->insert(static_cast<MessageRouting>(metaEnum.value(i)), false);
}
}
示例13: 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);
}
}
示例14: setRouting
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);
}
}
}
示例15: 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;
}