本文整理汇总了C++中QMetaEnum::key方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaEnum::key方法的具体用法?C++ QMetaEnum::key怎么用?C++ QMetaEnum::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaEnum
的用法示例。
在下文中一共展示了QMetaEnum::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
SkillEdit::SkillEdit(QWidget *parent) :
QWidget(parent),
ui(new Ui::SkillEdit),
d(*new SkillEditPrivate)
{
ui->setupUi(this);
//Find repository
Repository *repo = REPOSITORY("Skill");
Q_ASSERT(repo);
//Set up the filter model
d.model = new QSortFilterProxyModel(this);
d.model->setSourceModel(repo);
d.model->setFilterKeyColumn(repo->column("name"));
d.model->setFilterCaseSensitivity(Qt::CaseInsensitive);
//Create the dock widget
d.dockWidget = new SkillsDockWidget(d.model);
//Configure the button box
ui->buttonBox->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
//Add skill bases to their combobox
QMetaEnum skillBaseEnum = ORM()->metaEnum("SkillBase");
for (int i=0; i<skillBaseEnum.keyCount(); ++i) {
ui->base->addItem(skillBaseEnum.key(i));
}
//Add skill categories to their combobox
QMetaEnum skillCategoryEnum = ORM()->metaEnum("SkillCategory");
for (int i=0; i<skillCategoryEnum.keyCount(); ++i) {
ui->category->addItem(skillCategoryEnum.key(i));
}
//Set up the data widget mapper
d.mapper = new DataWidgetMapper(this);
d.mapper->setSubmitPolicy(DataWidgetMapper::ManualSubmit);
d.mapper->setModel(repo);
d.mapper->addMapping(ui->name, repo->column("name"));
d.mapper->addMapping(ui->base, repo->column("base"), "currentIndex");
d.mapper->addMapping(ui->category, repo->column("category"), "currentIndex");
d.mapper->addMapping(ui->rulesPage, repo->column("rulesPage"));
d.mapper->addMapping(ui->description, repo->column("description"));
d.mapper->addMapping(ui->dieResults, repo->column("dieResults"));
d.mapper->toFirst();
setStateUnmodified();
//Connect signals for un/modified data
connect(d.mapper, SIGNAL(dataChanged()), this, SLOT(setStateModified()));
//Connect signals for the button box
connect(ui->buttonBox, SIGNAL(accepted()), d.mapper, SLOT(submit()));
connect(ui->buttonBox, SIGNAL(rejected()), d.mapper, SLOT(revert()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(setStateUnmodified()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(setStateUnmodified()));
}
示例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: 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;
}
示例4: 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)));
}
}
}
示例5: 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);
}
示例6: setRestrictionsOfMenuBar
void UIMenuBarEditorWidget::setRestrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType restrictions)
{
/* Cache passed restrictions: */
m_restrictionsOfMenuBar = restrictions;
/* Get static meta-object: */
const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
/* We have UIExtraDataMetaDefs::MenuType enum registered, so we can enumerate it: */
const int iEnumIndex = smo.indexOfEnumerator("MenuType");
const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
/* Handle other enum-values: */
for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
{
/* Get iterated enum-value: */
const UIExtraDataMetaDefs::MenuType enumValue =
static_cast<const UIExtraDataMetaDefs::MenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
/* Skip MenuType_Invalid & MenuType_All enum-value: */
if (enumValue == UIExtraDataMetaDefs::MenuType_Invalid ||
enumValue == UIExtraDataMetaDefs::MenuType_All)
continue;
/* Which key required action registered under? */
const QString strKey = gpConverter->toInternalString(enumValue);
if (!m_actions.contains(strKey))
continue;
/* Update action 'checked' state: */
m_actions.value(strKey)->setChecked(!(m_restrictionsOfMenuBar & enumValue));
}
}
示例7: ComboBoxEditor
QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
{
ComboBoxEditor *editor = new ComboBoxEditor(parent,false);
connect(editor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotEnumChanged(QString)));
QStringList enumValues;
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
for (int i=0;i<propEnum.keyCount();i++){
if (m_acceptableValues.isEmpty()) enumValues.append(propEnum.key(i));
else {
if (m_acceptableValues.contains(propEnum.value(i))){
enumValues.append(propEnum.key(i));
}
}
}
editor->addItems(enumValues);
return editor;
}
示例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: initFrom
void ThemeSettingsTableModel::initFrom(Theme *theme)
{
const QMetaObject &metaObject = Theme::staticMetaObject;
// Colors
{
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("Color"));
QMap<QString, ColorVariable::Ptr> varLookup;
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QPair<QColor, QString> c = theme->d->colors[static_cast<Theme::Color>(i)];
if (c.second.isEmpty()) {
ColorVariable::Ptr v = colors()->createVariable(c.first);
colors()->createRole(key, v);
} else if (varLookup.contains(c.second)) {
colors()->createRole(key, varLookup[c.second]);
} else {
ColorVariable::Ptr v = colors()->createVariable(c.first, c.second);
colors()->createRole(key, v);
varLookup[c.second] = v;
}
}
}
// Flags
{
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("Flag"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
m_flags.append(qMakePair(key, theme->flag(static_cast<Theme::Flag>(i))));
}
}
// ImageFiles
{
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("ImageFile"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
m_imageFiles.append(qMakePair(key, theme->imageFile(static_cast<Theme::ImageFile>(i), QString())));
}
}
m_widgetStyle = theme->widgetStyle();
m_name = theme->d->name;
m_preferredStyles = theme->d->preferredStyles;
}
示例10: setUnit
void QEther::setUnit(QString const& _unit)
{
try
{
QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit"));
for (int k = 0; k < units.keyCount(); k++)
{
if (QString(units.key(k)).toLower() == _unit.toLower())
{
m_currentUnit = static_cast<EtherUnit>(units.keysToValue(units.key(k)));
return;
}
}
}
catch (...)
{
manageException();
}
}
示例11: 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;
}
示例12: 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));
}
}
示例13: createCurveIcons
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);
}
}
示例14: 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);
}
}
示例15: enumToString
QString enumToString(const QMetaEnum &aMetaEnum, const int &aValue)
{
QString res=qApp->translate("Property", "[No enumeration value]");
for (int i=0; i<aMetaEnum.keyCount(); ++i)
{
if (aMetaEnum.value(i)==aValue)
{
res=QString::fromLatin1(aMetaEnum.key(i));
break;
}
}
return res;
}