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


C++ DoubleSpinBox::cleanText方法代码示例

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


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

示例1: setModelData

void SettingsDelegate::setModelData(QWidget* editor,
                                    QAbstractItemModel* model,
                                    const QModelIndex& index) const
{
    // Get the setting type.
    int type = index.model()->data(index, SettingsModel::TypeRole).toInt();

    // Get the editor data.
    QVariant value;
    switch (type)
    {
        case SettingsValue::INT:
        case SettingsValue::UNSIGNED_INT:
        case SettingsValue::INT_POSITIVE:
        {
            // Spin box editors.
            value = static_cast<QSpinBox*>(editor)->value();
            break;
        }
        case SettingsValue::DOUBLE:
        case SettingsValue::UNSIGNED_DOUBLE:
        case SettingsValue::DOUBLE_RANGE:
        {
            // Double spin box editors.
            value = static_cast<DoubleSpinBox*>(editor)->cleanText();
            break;
        }
        case SettingsValue::DOUBLE_RANGE_EXT:
        {
            // Double spin box editors.
            DoubleSpinBox* e = static_cast<DoubleSpinBox*>(editor);
            double v = e->value();
            value = e->value();
            if (v <= e->rangeMin())
                value = e->minText();
            else
                value = e->cleanText();
            break;
        }
        case SettingsValue::DATE_TIME:
        {
            // Date and time editors.
            value = static_cast<QLineEdit*>(editor)->text();
            // Validate these strings...
            //      d-M-yyyy h:m:s.z
            //      yyyy/M/d/h:m:s.z
            //      yyyy-M-d h:m:s.z
            //      yyyy-M-dTh:m:s.z
            //      MJD.fraction
            QString h = "([01]?[0-9]|2[0-3])";       // 00-23
            QString m = "[0-5]?[0-9]";               // 00-59
            QString s = m;
            QString z = "(\\.\\d{1,3})?";            // 000-999
            QString d = "(0?[1-9]|[12][0-9]|3[01])"; // 01-31
            QString M = "(|1[0-2]|0?[1-9]|)";        // 01-12
            QString y = "\\d{4,4}";                  // yyyy
            QString rtime  = h+":"+m+":"+s+z;        // h:m:s.zzz
            QString rdate1 = "("+d+"-"+M+"-"+y+"\\s"+rtime+")";
            QString rdate2 = "("+y+"/"+M+"/"+d+"/"+rtime+")";
            QString rdate3 = "("+y+"-"+M+"-"+d+"\\s"+rtime+")";
            QString rdate4 = "("+y+"-"+M+"-"+d+"T"+rtime+")";
            QString rdate5 = "(\\d+\\.?\\d*)";
            QString rdate6 = "(\\d+\\.?\\d*[e|E]-?\\d{1,2})";
            QString rdatetime = rdate1+"|"+rdate2+"|"+rdate3+"|"+rdate4+
                            "|"+rdate5+"|"+rdate6;
            QRegExpValidator validator(QRegExp(rdatetime), 0);
            int pos = 0;
            QString v = value.toString();
            if (validator.validate(v, pos) != QValidator::Acceptable &&
                            !v.isEmpty()) {
                cerr << "WARNING: DateTime value failed to validate." << endl;
                return;
            }
            break;
        }
        case SettingsValue::TIME:
        {
            // Time editors.
            value = static_cast<QLineEdit*>(editor)->text();
            QString h = "(\\d+)";                    // >= 0
            QString m = "[0-5]?[0-9]";               // 00-59
            QString s = m;
            QString z = "(\\.\\d{1,8})?";            // 000-99999999
            QString rtime  = h+":"+m+":"+s+z;        // h:m:s.zzz
            QString sec    = "(\\d+\\.?\\d*)";
            QString exp_sec = "(\\d+\\.?\\d*[e|E]-?\\d{1,2})";
            QRegExpValidator validator(QRegExp(rtime+"|"+sec+"|"+exp_sec), 0);
            int pos = 0;
            QString v = value.toString();
            if (validator.validate(v, pos) != QValidator::Acceptable &&
                            !v.isEmpty()) {
                cerr << "WARNING: Time value failed to validate." << endl;
                return;
            }
            break;
        }
        case SettingsValue::RANDOM_SEED:
        {
            // Random seed editors.
            int val = static_cast<QSpinBox*>(editor)->value();
//.........这里部分代码省略.........
开发者ID:OxfordSKA,项目名称:OSKAR,代码行数:101,代码来源:oskar_SettingsDelegate.cpp


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