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


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

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


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

示例1: text

/*!
    \property QProgressBar::text
    \brief the descriptive text shown with the progress bar

    The text returned is the same as the text displayed in the center
    (or in some styles, to the left) of the progress bar.

    The progress shown in the text may be smaller than the minimum value,
    indicating that the progress bar is in the "reset" state before any
    progress is set.

    In the default implementation, the text either contains a percentage
    value that indicates the progress so far, or it is blank because the
    progress bar is in the reset state.
*/
QString QProgressBar::text() const
{
    Q_D(const QProgressBar);
    if ((d->maximum == 0 && d->minimum == 0) || d->value < d->minimum
            || (d->value == INT_MIN && d->minimum == INT_MIN))
        return QString();

    qint64 totalSteps = qint64(d->maximum) - d->minimum;

    QString result = d->format;
    QLocale locale = d->locale; // Omit group separators for compatibility with previous versions that were non-localized.
    locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator);
    result.replace(QLatin1String("%m"), locale.toString(totalSteps));
    result.replace(QLatin1String("%v"), locale.toString(d->value));

    // If max and min are equal and we get this far, it means that the
    // progress bar has one step and that we are on that step. Return
    // 100% here in order to avoid division by zero further down.
    if (totalSteps == 0) {
        result.replace(QLatin1String("%p"), locale.toString(int(100)));
        return result;
    }

    int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps;
    result.replace(QLatin1String("%p"), locale.toString(progress));
    return result;
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:42,代码来源:qprogressbar.cpp

示例2: testGetNumeric

void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
{
    SpinBoxType *sbox = qFindChild<SpinBoxType *>(dialog);
    QVERIFY(sbox != 0);

    QLineEdit *ledit = qFindChild<QLineEdit *>(static_cast<QObject *>(sbox));
    QVERIFY(ledit != 0);

    QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
    QVERIFY(bbox != 0);
    QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
    QVERIFY(okButton != 0);

    QVERIFY(sbox->value() >= sbox->minimum());
    QVERIFY(sbox->value() <= sbox->maximum());
    QVERIFY(sbox->hasAcceptableInput());
    QLocale loc;
    QCOMPARE(
        normalizeNumericString(ledit->selectedText()),
        normalizeNumericString(loc.toString(sbox->value())));
    QVERIFY(okButton->isEnabled());

    const ValueType origValue = sbox->value();

    testInvalidateAndRestore<SpinBoxType, ValueType>(sbox, okButton, ledit);
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum() - 1));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum() + 1));
    testTypingValue<SpinBoxType>(sbox, okButton, "0");
    testTypingValue<SpinBoxType>(sbox, okButton, "0.0");
    testTypingValue<SpinBoxType>(sbox, okButton, "foobar");

    testTypingValue<SpinBoxType>(sbox, okButton, loc.toString(origValue));
}
开发者ID:dewhisna,项目名称:emscripten-qt,代码行数:35,代码来源:tst_qinputdialog.cpp

示例3: updateValues

// -------------------------------------------------------------------------------------------------
void ParameterBox::updateValues() throw ()
{
    QLocale loc;
    
    // update the left value
    if (m_leftValue < 0.0)
    {
        m_leftMarker->setText(tr("(no marker)"));
    }
    else
    {
        m_leftMarker->setText(loc.toString(m_leftValue, 'f', 4) + " ms");
    }
    
    
    // update the right value
    if (m_rightValue < 0.0)
    {
        m_rightMarker->setText(tr("(no marker)"));
    }
    else
    {
        m_rightMarker->setText(loc.toString(m_rightValue, 'f', 4) + " ms");
    }
    
    // update the diff display
    if (m_leftValue < 0.0 || m_rightValue < 0.0)
    {
        m_diff->setText(tr("(no difference)"));
    }
    else
    {
        m_diff->setText(loc.toString(m_rightValue - m_leftValue, 'f', 4) + " ms");
    }
}
开发者ID:BackupTheBerlios,项目名称:tfla-01-svn,代码行数:36,代码来源:parameterbox.cpp

示例4: readableSize

// Returns the size in human readable format
QString MainWindow::readableSize( qint64 size ) const
{
    static const QString sizeStrs[] = {
        tr("B"), tr("KiB"), tr("MiB"), tr("GiB"), tr("TiB") };

    QLocale defaultLocale;
    unsigned int i;
    double humanSize = size;

    for ( i=0; i+1 < (sizeof(sizeStrs)/sizeof(QString)) && (humanSize/1024.0) >= 1024.0; i++ )
        humanSize /= 1024.0;

    if ( humanSize >= 1024.0 ) {
        humanSize /= 1024.0;
        i++;
    }

    QString output;
    if ( i == 0 )
        // No decimal part if we display straight bytes.
        output = defaultLocale.toString( (int) humanSize );
    else
        output = defaultLocale.toString( humanSize, 'f', 1 );

    output += QString(" ") + sizeStrs[i];

    return output;
}
开发者ID:sebi2k1,项目名称:glogg,代码行数:29,代码来源:mainwindow.cpp

示例5: logFitInfo

QString MultiPeakFit::logFitInfo(int iterations, int status)
{
	QString info = Fit::logFitInfo(iterations, status);
	if (d_peaks == 1)
		return info;

    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();

	info += tr("Peak") + "\t" + tr("Area") + "\t";
	info += tr("Center") + "\t" + tr("Width") + "\t" + tr("Height") + "\n";
	info += "---------------------------------------------------------------------------------------\n";
	for (int j=0; j<d_peaks; j++){
		info += QString::number(j+1) + "\t";
		info += locale.toString(d_results[3*j], 'e', d_prec) + "\t";
		info += locale.toString(d_results[3*j+1], 'e', d_prec) + "\t";
		info += locale.toString(d_results[3*j+2], 'e', d_prec) + "\t";

		if (d_profile == Lorentz)
			info += locale.toString(M_2_PI*d_results[3*j]/d_results[3*j+2], 'e', d_prec) + "\n";
		else
			info += locale.toString(sqrt(M_2_PI)*d_results[3*j]/d_results[3*j+2], 'e', d_prec) + "\n";
	}
	info += "---------------------------------------------------------------------------------------\n";
	return info;
}
开发者ID:chaoqing,项目名称:qtiplot,代码行数:26,代码来源:MultiPeakFit.cpp

示例6: updateStatistics

void SupportedProtocolsDialog::updateStatistics()
{
    QLocale locale = QLocale::system();
    QString hint = tr("%1 protocols, %2 fields.")
            .arg(locale.toString(ui->protoTreeWidget->topLevelItemCount()))
            .arg(locale.toString(field_count_));
    ui->hintLabel->setText(hint);
}
开发者ID:bbidulock,项目名称:wireshark,代码行数:8,代码来源:supported_protocols_dialog.cpp

示例7: updateStatistics

void SupportedProtocolsDialog::updateStatistics()
{
    QLocale locale = QLocale::system();
    QString hint = tr("%1 protocols, %2 fields.")
                   .arg(locale.toString(ui->protoTreeWidget->topLevelItemCount()))
                   .arg(locale.toString(field_count_));
    ui->hintLabel->setText(hint);
    wsApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 1);
}
开发者ID:forname,项目名称:wireshark,代码行数:9,代码来源:supported_protocols_dialog.cpp

示例8: output

void Differentiation::output()
{
    double *result = new double[d_n - 1];
	for (int i = 1; i < d_n - 1; i++){
		double xl = d_x[i - 1];
		double xc = d_x[i];
		double xr = d_x[i + 1];

		if (xr != xc && xl != xc)
			result[i] = 0.5*((d_y[i + 1] - d_y[i])/(xr - xc) + (d_y[i] - d_y[i - 1])/(xc - xl));
		else if (xr != xc)
			result[i] = (d_y[i + 1] - d_y[i])/(xr - xc);
		else if (xl != xc)
			result[i] = (d_y[i] - d_y[i - 1])/(xc - xl);
		else
			result[i] = result[i - 1];
	}

    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();
    QString tableName = app->generateUniqueName(QString(objectName()));
    QString dataSet;
	if (d_curve)
		dataSet = d_curve->title().text();
	else
		dataSet = d_y_col_name;

    int prec = app->d_decimal_digits;
	int rows = d_n - 2;
	int col = 1;
	if (!d_result_table || d_result_table->numRows() < rows){
		d_result_table = app->newHiddenTable(tableName, tr("Derivative") + " " + tr("of", "Derivative of")  + " " + dataSet, rows, 2);
		for (int i = 1; i < d_n-1; i++) {
			int aux = i - 1;
			d_result_table->setText(aux, 0, locale.toString(d_x[i], 'g', prec));
			d_result_table->setText(aux, 1, locale.toString(result[i], 'g', prec));
		}
	} else {
		col = d_result_table->numCols();
		d_result_table->addCol();
		for (int i = 1; i < d_n-1; i++)
			d_result_table->setText(i - 1, col, locale.toString(result[i], 'g', prec));
	}

    delete[] result;

	if (d_graphics_display){
		if (!d_output_graph){
			createOutputGraph();
			d_output_graph->removeLegend();
		}

		d_output_graph->insertCurve(d_result_table, d_result_table->colLabel(col), 0);
		if (d_update_output_graph)
			d_output_graph->updatePlot();
	}
}
开发者ID:chaoqing,项目名称:qtiplot,代码行数:57,代码来源:Differentiation.cpp

示例9: localeChanged

void NumberFormatsWidget::localeChanged(QLocale locale)
{
    number1->setText(locale.toString(-123456));
    number2->setText(locale.toString(1234.56, 'f', 2));
    number3->setText(locale.toString(1234.56, 'e', 4));

    measurementSystem->setText(
                locale.measurementSystem() == QLocale::ImperialSystem ? "US" : "Metric");
}
开发者ID:maxxant,项目名称:qt,代码行数:9,代码来源:numberformats.cpp

示例10: toPercent

QString CallgrindHelper::toPercent(float costs, const QLocale &locale)
{
    if (costs > 99.9f)
        return locale.toString(100) + locale.percent();
    if (costs > 9.99f)
        return locale.toString(costs, 'f', 1) + locale.percent();
    if (costs > 0.009f)
        return locale.toString(costs, 'f', 2) + locale.percent();
    return QString("<") + locale.toString(0.01f) + locale.percent();
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例11: toCSV

QStringList PluginGauss::toCSV(const QJsonObject& data, const QLocale& csvLocale)
{
    QStringList list;
    list << csvLocale.toString(data[DATE_GAUSS_AGE_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_ERROR_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_A_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_B_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_C_STR].toDouble());
    return list;
}
开发者ID:chrono35,项目名称:chronomodel,代码行数:10,代码来源:PluginGauss.cpp

示例12: datetimeToString

QString datetimeToString(QDateTime datetime)
{
    QLocale locale;

    // return time for today or date for older
    if (datetime.date() == QDate::currentDate())
        return locale.toString(datetime.time(), QLocale::NarrowFormat);

    return locale.toString(datetime.date(), QLocale::NarrowFormat);
}
开发者ID:Tofee,项目名称:space-inspector,代码行数:10,代码来源:globals.cpp

示例13: info

 QStringList LightInSurfacePosition::info() const
{
	QLocale locale; 
	auto position4 = m_transformation * make_float4(initialPosition, 1.0f);
	auto position = optix::make_float3(position4 / position4.w);
	auto x = locale.toString(position.x, 'f', 2);
	auto y = locale.toString(position.y, 'f', 2);
	auto z = locale.toString(position.z, 'f', 2);
	return QStringList() << x << y << z;
}
开发者ID:igui,项目名称:RPSolver,代码行数:10,代码来源:LightInSurfacePosition.cpp

示例14:

QStringList Plugin14C::toCSV(const QJsonObject& data, const QLocale& csvLocale)
{
    QStringList list;
    list << csvLocale.toString(data[DATE_14C_AGE_STR].toDouble());
    list << csvLocale.toString(data[DATE_14C_ERROR_STR].toDouble());
    list << data[DATE_14C_REF_CURVE_STR].toString();
    list << csvLocale.toString(data[DATE_14C_DELTA_R_STR].toDouble());
    list << csvLocale.toString(data[DATE_14C_DELTA_R_ERROR_STR].toDouble());
    return list;
}
开发者ID:chrono35,项目名称:chronomodel,代码行数:10,代码来源:Plugin14C.cpp

示例15: updateDate

void MyCalendar::updateDate()
{
    QDateTime dateTmp;
    int currentDay;
    QLocale local = QLocale::English;
    if (local.toString(date, "ddd") == "Sun")
        currentDay = 0;
    else if (local.toString(date, "ddd") == "Mon")
        currentDay = 1;
    else if (local.toString(date, "ddd") == "Tue")
        currentDay = 2;
    else if (local.toString(date, "ddd") == "Wed")
        currentDay = 3;
    else if (local.toString(date, "ddd") == "Thu")
        currentDay = 4;
    else if (local.toString(date, "ddd") == "Fri")
        currentDay = 5;
    else if (local.toString(date, "ddd") == "Sat")
        currentDay = 6;

    for(int i = 0; i < 7; i++)
    {
        dateTmp = date.addDays(-currentDay + i);
        ui->scheduleTable->setItem(0, i + 1, new QTableWidgetItem(local.toString(dateTmp,"yy/MM/dd ddd.")));
    }
}
开发者ID:abbasid,项目名称:myCalendar_ver2,代码行数:26,代码来源:mycalendar.cpp


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