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


C++ QLocale::toDouble方法代码示例

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


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

示例1: getSpacing

dvec3 RawDataReaderDialogQt::getSpacing() const {
    QLocale locale = spaceX_->locale();
    glm::dvec3 space(0.01f);
    
    space.x = locale.toDouble(spaceX_->text().remove(QChar(' ')));
    space.y = locale.toDouble(spaceY_->text().remove(QChar(' ')));
    space.z = locale.toDouble(spaceZ_->text().remove(QChar(' ')));

    return space;
}
开发者ID:Ojaswi,项目名称:inviwo,代码行数:10,代码来源:rawdatareaderdialogqt.cpp

示例2: guessParameters

QStringList NonLinearFit::guessParameters(const QString& s, bool *error, string *errMsg)
{
	QString text = s;
	text.remove(QRegExp("\\s")).remove(".");

	QStringList parList;
	try {
		MyParser parser;
		ParserTokenReader reader(&parser);

		QLocale locale = QLocale();

		const char *formula = text.toAscii().data();
		int length = text.toAscii().length();
		reader.SetFormula (formula);
		reader.IgnoreUndefVar(true);
		int pos = 0;
		while(pos < length){
			ParserToken<value_type, string_type> token = reader.ReadNextToken();
			QString str = QString(token.GetAsString().c_str());

			bool isNumber;
			locale.toDouble(str, &isNumber);

			if (token.GetCode () == cmVAR && str.contains(QRegExp("\\D"))
				&& str != "x" && !parList.contains(str) && !isNumber){
				if (str.endsWith("e", Qt::CaseInsensitive) &&
					str.count("e", Qt::CaseInsensitive) == 1){

					QString aux = str;
					aux.remove("e", Qt::CaseInsensitive);

					bool auxIsNumber;
					locale.toDouble(aux, &auxIsNumber);
					if (!auxIsNumber)
						parList << str;
				} else
					parList << str;
			}

			pos = reader.GetPos();
		}
		parList.sort();
	} catch(mu::ParserError &e) {
		if (error){
			*error = true;
			*errMsg = e.GetMsg();
		}
		return parList;
	}
	if (error)
		*error = false;
	return parList;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:54,代码来源:NonLinearFit.cpp

示例3: loadData

void VectorCurve::loadData() {
  if (!plot())
    return;

  int xcol = d_table->colIndex(d_x_column);
  int ycol = d_table->colIndex(title().text());
  int endXCol = d_table->colIndex(d_end_x_a);
  int endYCol = d_table->colIndex(d_end_y_m);

  int rows = abs(d_end_row - d_start_row) + 1;
  QVector<double> X(rows), Y(rows), X2(rows), Y2(rows);
  int size = 0;
  QLocale locale = plot()->locale();
  for (int i = d_start_row; i <= d_end_row; i++) {
    QString xval = d_table->text(i, xcol);
    QString yval = d_table->text(i, ycol);
    QString xend = d_table->text(i, endXCol);
    QString yend = d_table->text(i, endYCol);
    if (!xval.isEmpty() && !yval.isEmpty() && !xend.isEmpty() &&
        !yend.isEmpty()) {
      bool valid_data = true;
      X[size] = locale.toDouble(xval, &valid_data);
      if (!valid_data)
        continue;
      Y[size] = locale.toDouble(yval, &valid_data);
      if (!valid_data)
        continue;
      X2[size] = locale.toDouble(xend, &valid_data);
      if (!valid_data)
        continue;
      Y2[size] = locale.toDouble(yend, &valid_data);
      if (valid_data)
        size++;
    }
  }

  if (!size)
    return;

  X.resize(size);
  Y.resize(size);
  X2.resize(size);
  Y2.resize(size);
  setData(X.data(), Y.data(), size);
  foreach (DataCurve *c, d_error_bars)
    c->setData(X.data(), Y.data(), size);
  setVectorEnd(X2, Y2);
}
开发者ID:liyulun,项目名称:mantid,代码行数:48,代码来源:VectorCurve.cpp

示例4: method_fromLocaleString

QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
    if (ctx->argc() < 1 || ctx->argc() > 2)
        V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");

    int numberIdx = 0;
    QLocale locale;

    QV4::Scope scope(ctx);

    if (ctx->argc() == 2) {
        if (!isLocaleObject(ctx->args()[0]))
            V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");

        GET_LOCALE_DATA_RESOURCE(ctx->args()[0]);
        locale = r->d()->locale;

        numberIdx = 1;
    }

    QString ns = ctx->args()[numberIdx].toQString();
    if (!ns.length())
        return QV4::Encode(Q_QNAN);

    bool ok = false;
    double val = locale.toDouble(ns, &ok);

    if (!ok)
        V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid format")

    return QV4::Encode(val);
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:32,代码来源:qqmllocale.cpp

示例5: qDebug

MapValidator::QValidator::State MapValidator::validate(QString &s, int &i) const
{
    qDebug()<<"validating table input";
    if (s.isEmpty() || s == "-") {
        return QValidator::Intermediate;
    }

    QLocale locale;

    QChar decimalPoint = locale.decimalPoint();
    int charsAfterPoint = s.length() - s.indexOf(decimalPoint) -1;

    if (charsAfterPoint > decimals() && s.indexOf(decimalPoint) != -1) {
        return QValidator::Invalid;
    }

    bool ok;
    double d = locale.toDouble(s, &ok);

    if (ok && d >= bottom() && d <= top()) {
        return QValidator::Acceptable;
    } else {
        return QValidator::Invalid;
    }
}
开发者ID:JordanDickson,项目名称:GroundStation,代码行数:25,代码来源:mapvalidator.cpp

示例6: slotAdjustKeyframeInfo

void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
{
    QTableWidgetItem *item = keyframe_list->currentItem();
    if (!item)
        return;
    int min = m_min;
    int max = m_max;
    QTableWidgetItem *above = keyframe_list->item(item->row() - 1, item->column());
    QTableWidgetItem *below = keyframe_list->item(item->row() + 1, item->column());
    if (above)
        min = getPos(above->row()) + 1;
    if (below)
        max = getPos(below->row()) - 1;

    m_position->blockSignals(true);
    m_position->setRange(min, max, true);
    m_position->setPosition(getPos(item->row()));
    m_position->blockSignals(false);
    QLocale locale;

    for (int col = 0; col < keyframe_list->columnCount(); ++col) {
        DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
        if (!doubleparam)
            continue;
        doubleparam->blockSignals(true);
        if (keyframe_list->item(item->row(), col)) {
            doubleparam->setValue(locale.toDouble(keyframe_list->item(item->row(), col)->text()));
        } else {
            //qDebug() << "Null pointer exception caught: http://www.kdenlive.org/mantis/view.php?id=1771";
        }
        doubleparam->blockSignals(false);
    }
    if (KdenliveSettings::keyframeseek() && seek)
        emit seekToPos(m_position->getPosition() - m_min);
}
开发者ID:alstef,项目名称:kdenlive,代码行数:35,代码来源:keyframeedit.cpp

示例7: fromString

void CubicBezierSpline::fromString(const QString& spline)
{
    m_points.clear();
    QLocale locale;
    const QStringList bpoints = spline.split(QLatin1Char('|'));
    foreach(const QString &bpoint, bpoints) {
        const QStringList points = bpoint.split(QLatin1Char('#'));
        QVector <QPointF> values;
        foreach(const QString &point, points) {
            QStringList xy = point.split(QLatin1Char(';'));
            if (xy.count() == 2)
                values.append(QPointF(locale.toDouble(xy.at(0)), locale.toDouble(xy.at(1))));
        }
        if (values.count() == 3) {
            m_points.append(BPoint(values.at(0), values.at(1), values.at(2)));
        }
    }
开发者ID:kamalmostafa,项目名称:kdenlive,代码行数:17,代码来源:cubicbezierspline.cpp

示例8: setText

void BitcoinAmountField::setText(const QString &text)
{
    if (text.isEmpty())
        amount->clear();
    else {
        QLocale locale;
        amount->setValue(locale.toDouble(text));
    }
}
开发者ID:1000010,项目名称:koin,代码行数:9,代码来源:bitcoinamountfield.cpp

示例9: parseDouble

double LonLatParser::parseDouble(const QString& input)
{
    // Decide by decimalpoint if system locale or C locale should be tried.
    // Otherwise if first trying with a system locale when the string is in C locale,
    // the "." might be misinterpreted as thousands group separator and thus a wrong
    // value yielded
    QLocale locale = QLocale::system();
    return input.contains(locale.decimalPoint()) ? locale.toDouble(input) : input.toDouble();
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: updateDecimalSeparators

void PreviewTable::updateDecimalSeparators(const QLocale& oldSeparators)
{
	QLocale locale = ((QWidget *)parent())->locale();
	for (int i=0; i<numCols(); i++){
        for (int j=0; j<numRows(); j++){
            if (!text(j, i).isEmpty()){
				double val = oldSeparators.toDouble(text(j, i));
                setText(j, i, locale.toString(val, 'g', d_numeric_precision));
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:12,代码来源:ImportASCIIDialog.cpp

示例11: QLocale

/*!
 * \brief GUI::ChangeDeleteUserDialog::slotSetValue
 * Ersetzt Komma durch Punkt für eine einheithliche Eingabe.
 * Überprüft ob der eingetragene Wert ein double ist.
 * \param value
 */
void GUI::ChangeDeleteUserDialog::slotSetValue(QString value)
{
    if(value.contains(",",Qt::CaseSensitive))
        value.replace(",",".");

    QLocale locale = QLocale(QLocale::English, QLocale::UnitedStates);

    if(!locale.toDouble(value) && value != "0"  && value != "0." && value != "-0" && value != "-0." && value != "-" && value !="")
    {
        QMessageBox::information(this, "Wert", tr("Betrag ungueltig").toLatin1());
    }
    ui->balanceLineEdit->setText(value);
}
开发者ID:Traxes,项目名称:SE,代码行数:19,代码来源:changedeleteuserdialog.cpp

示例12: rx

void K3b::FillStatusDisplay::slotCustomSize()
{
    // allow the units to be translated
    QString gbS = i18n("GB");
    QString mbS = i18n("MB");
    QString minS = i18n("min");

    QLocale const locale = QLocale::system();

    // we certainly do not have BD- or HD-DVD-only projects
    QString defaultCustom;
    if( d->doc->supportedMediaTypes() & K3b::Device::MEDIA_CD_ALL ) {
        defaultCustom = d->showTime ? QString("74") + minS : QString("650") + mbS;
    }
    else {
        defaultCustom = locale.toString(4.4,'g',1) + gbS;
    }

    QRegExp rx( QString("(\\d+\\") + locale.decimalPoint() + "?\\d*)(" + gbS + '|' + mbS + '|' + minS + ")?" );
    QRegExpValidator validator( rx, this );
    bool ok;
    QString size = QInputDialog::getText( this,
                                          i18n("Custom Size"),
                                          i18n("<p>Please specify the size of the medium. Use suffixes <b>GB</b>,<b>MB</b>, "
                                               "and <b>min</b> for <em>gigabytes</em>, <em>megabytes</em>, and <em>minutes</em>"
                                               " respectively."),
                                          QLineEdit::Normal,
                                          defaultCustom,
                                          &ok );

    int validatorPos;
    if( ok && validator.validate( size, validatorPos ) ) {
        // determine size
        if( rx.exactMatch( size ) ) {
            QString valStr = rx.cap(1);
            if( valStr.endsWith( locale.decimalPoint() ) )
                valStr += '0';
            double val = locale.toDouble( valStr, &ok );
            if( ok ) {
                QString s = rx.cap(2);
                if( s == gbS )
                    val *= 1024*512;
                else if( s == mbS || (s.isEmpty() && !d->showTime) )
                    val *= 512;
                else
                    val *= 60*75;
                d->setCdSize( static_cast<int>( val ) );
            }
        }
    }
}
开发者ID:KDE,项目名称:k3b,代码行数:51,代码来源:k3bfillstatusdisplay.cpp

示例13: insertKeyframe

void AbstractClipItem::insertKeyframe(QDomElement effect, int pos, double val, bool defaultValue)
{
    if (effect.attribute(QStringLiteral("disable")) == QLatin1String("1")) return;
    QLocale locale;
    locale.setNumberOptions(QLocale::OmitGroupSeparator);
    effect.setAttribute(QStringLiteral("active_keyframe"), pos);
    QDomNodeList params = effect.elementsByTagName(QStringLiteral("parameter"));
    for (int i = 0; i < params.count(); ++i) {
        QDomElement e = params.item(i).toElement();
        if (e.isNull()) continue;
        QString paramName = e.attribute(QStringLiteral("name"));
        if (e.attribute(QStringLiteral("type")) == QLatin1String("animated")) {
            if (!m_keyframeView.activeParam(paramName)) {
                continue;
            }
	    if (defaultValue) {
		m_keyframeView.addDefaultKeyframe(pos, m_keyframeView.type(pos));
	    } else {
		m_keyframeView.addKeyframe(pos, val, m_keyframeView.type(pos));
	    }
            e.setAttribute(QStringLiteral("value"), m_keyframeView.serialize());
        }
        else if (e.attribute(QStringLiteral("type")) == QLatin1String("keyframe")
            || e.attribute(QStringLiteral("type")) == QLatin1String("simplekeyframe")) {
            QString kfr = e.attribute(QStringLiteral("keyframes"));
            const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
            QStringList newkfr;
            bool added = false;
            foreach(const QString &str, keyframes) {
                int kpos = str.section('=', 0, 0).toInt();
                double newval = locale.toDouble(str.section('=', 1, 1));
                if (kpos < pos) {
                    newkfr.append(str);
                } else if (!added) {
                    if (i == m_visibleParam)
                        newkfr.append(QString::number(pos) + '=' + QString::number((int)val));
                    else
                        newkfr.append(QString::number(pos) + '=' + locale.toString(newval));
                    if (kpos > pos) newkfr.append(str);
                    added = true;
                } else newkfr.append(str);
            }
            if (!added) {
                if (i == m_visibleParam)
                    newkfr.append(QString::number(pos) + '=' + QString::number((int)val));
                else
                    newkfr.append(QString::number(pos) + '=' + e.attribute(QStringLiteral("default")));
            }
            e.setAttribute(QStringLiteral("keyframes"), newkfr.join(QStringLiteral(";")));
        }
开发者ID:jessezwd,项目名称:kdenlive,代码行数:50,代码来源:abstractclipitem.cpp

示例14: txtNeu

QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomElement &xml)
{
    QDomNodeList attribs = xml.elementsByTagName(QStringLiteral("parameter"));
    QMap<QString, QString> map;
    QLocale locale;
    for (int i = 0; i < attribs.count(); ++i) {
        QDomElement e = attribs.item(i).toElement();
        QString name = e.attribute(QStringLiteral("name"));
        map[name] = e.attribute(QStringLiteral("default"));
        if (e.hasAttribute(QStringLiteral("value"))) {
            map[name] = e.attribute(QStringLiteral("value"));
        }
        double factor = e.attribute(QStringLiteral("factor"), QStringLiteral("1")).toDouble();
        double offset = e.attribute(QStringLiteral("offset"), QStringLiteral("0")).toDouble();
        if (factor!= 1 || offset != 0) {
            if (e.attribute(QStringLiteral("type")) == QLatin1String("simplekeyframe")) {
                QStringList values = e.attribute(QStringLiteral("value")).split(';', QString::SkipEmptyParts);
                for (int j = 0; j < values.count(); ++j) {
                    QString pos = values.at(j).section(QLatin1Char('='), 0, 0);
                    double val = (values.at(j).section(QLatin1Char('='), 1, 1).toDouble() - offset) / factor;
                    values[j] = pos + '=' + locale.toString(val);
                }
                map[name] = values.join(QLatin1Char(';'));
            } else if (e.attribute(QStringLiteral("type")) != QLatin1String("addedgeometry")) {
                map[name] = locale.toString((locale.toDouble(map.value(name)) - offset) / factor);
                //map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
            }
        }
        if (e.attribute(QStringLiteral("namedesc")).contains(';')) {
            //TODO: Deprecated, does not seem used anywhere...
            QString format = e.attribute(QStringLiteral("format"));
            QStringList separators = format.split(QStringLiteral("%d"), QString::SkipEmptyParts);
            QStringList values = e.attribute(QStringLiteral("value")).split(QRegExp("[,:;x]"));
            QString neu;
            QTextStream txtNeu(&neu);
            if (values.size() > 0)
                txtNeu << (int)values[0].toDouble();
            int i = 0;
            for (i = 0; i < separators.size() && i + 1 < values.size(); ++i) {
                txtNeu << separators[i];
                txtNeu << (int)(values[i+1].toDouble());
            }
            if (i < separators.size())
                txtNeu << separators[i];
            map[e.attribute(QStringLiteral("name"))] = neu;
        }

    }
    return map;
}
开发者ID:jessezwd,项目名称:kdenlive,代码行数:50,代码来源:transitionhandler.cpp

示例15: loadData

void QwtPieCurve::loadData() {
  // Limit number of slices to 1000 - seems plenty and avoids potential crash
  // (#4470)
  if (abs(d_end_row - d_start_row) > 1000) {
    QString mess = QString("Pie charts are limited to 1000 segments!\n") +
                   QString("You asked for ") +
                   QString::number(abs(d_end_row - d_start_row)) +
                   QString(" - plotting only the first 1000.");
    QMessageBox::warning(qApp->topLevelWidgets()[0], "Pie chart", mess);
    d_end_row = d_start_row + 1000;
  }

  Plot *d_plot = static_cast<Plot *>(plot());
  QLocale locale = d_plot->locale();
  QVarLengthArray<double> X(abs(d_end_row - d_start_row) + 1);
  d_table_rows.resize(abs(d_end_row - d_start_row) + 1);

  int size = 0;
  int ycol = d_table->colIndex(title().text());
  for (int i = d_start_row; i <= d_end_row; i++) {
    QString xval = d_table->text(i, ycol);
    bool valid_data = true;
    if (!xval.isEmpty()) {
      X[size] = locale.toDouble(xval, &valid_data);
      if (valid_data) {
        d_table_rows[size] = i + 1;
        size++;
      }
    }
  }
  X.resize(size);
  d_table_rows.resize(size);
  setData(X.data(), X.data(), size);

  int labels = d_texts_list.size();
  // If there are no labels (initLabels() wasn't called yet) or if we have
  // enough labels: do nothing!
  if (d_texts_list.isEmpty() || labels == size)
    return;

  // Else add new pie labels.
  for (int i = labels; i < size; i++) {
    PieLabel *l = new PieLabel(d_plot, this);
    d_texts_list << l;
    l->hide();
  }
}
开发者ID:liyulun,项目名称:mantid,代码行数:47,代码来源:QwtPieCurve.cpp


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