本文整理汇总了C++中nlgeorges::UFormElm::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ UFormElm::getType方法的具体用法?C++ UFormElm::getType怎么用?C++ UFormElm::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlgeorges::UFormElm
的用法示例。
在下文中一共展示了UFormElm::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QColorDialog
QWidget *FormDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem & option ,
const QModelIndex &index) const
{
const CGeorgesFormProxyModel * mp = dynamic_cast<const CGeorgesFormProxyModel *>(index.model());
const CGeorgesFormModel * m = dynamic_cast<const CGeorgesFormModel *>(mp->sourceModel());
CFormItem *item = static_cast<CFormItem*>(mp->mapToSource(index).internalPointer());
QString value = item->data(1).toString();
if (value.isEmpty() || !mp || !m)
return 0;
CFormItem* curItem = m->getItem(mp->mapToSource(index));
NLGEORGES::UFormElm *curElm = curItem->getFormElm();
if (!curElm)
{
// TODO: create new Element
return 0;
}
const NLGEORGES::UType *type = curElm->getType();
if(type)
{
int numDefinitions = type->getNumDefinition();
if (numDefinitions)
{
std::string l, v;
QString label,value;
QComboBox *editor = new QComboBox(parent);
for (int i = 0; i < numDefinitions; i++)
{
type->getDefinition(i,l,v);
label = l.c_str();
value = v.c_str();
editor->addItem(label);
}
return editor;
}
else
{
switch (type->getType())
{
case NLGEORGES::UType::UnsignedInt:
case NLGEORGES::UType::SignedInt:
{
QSpinBox *editor = new QSpinBox(parent);
//QString min = QString(type->getMin().c_str());
//QString max = QString(type->getMax().c_str());
//QString inc = QString(type->getIncrement().c_str());
//nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toUtf8().constData());
// TODO: use saved min/max values
editor->setMinimum(-99999);
editor->setMaximum(99999);
editor->setSingleStep(1);
return editor;
}
case NLGEORGES::UType::Double:
{
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
//QString min = QString(type->getMin().c_str());
//QString max = QString(type->getMax().c_str());
//QString inc = QString(type->getIncrement().c_str());
//nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toStdString().c_str());
// TODO: use saved min/max values
editor->setMinimum(-99999);
editor->setMaximum(99999);
editor->setSingleStep(0.1);
editor->setDecimals(1);
return editor;
}
case NLGEORGES::UType::Color:
{
return new QColorDialog();
}
default: // UType::String
{
QLineEdit *editor = new QLineEdit(parent);
return editor;
}
}
}
}
return 0;
}