本文整理汇总了C++中QLocale::groupSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::groupSeparator方法的具体用法?C++ QLocale::groupSeparator怎么用?C++ QLocale::groupSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::groupSeparator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char **)
{
QTextStream out(stdout);
QLocale sysLoc = QLocale::system();
double value = 99999999999999999999999999999999.;
double max = 999999999999999999.99;
int decimals = 2;
//Q_ASSERT(value < max);
QString str = sysLoc.toString(value, 'f', decimals);
str.remove(sysLoc.groupSeparator());
out << str << endl;
return 0;
}
示例2: parseMoney
Money parseMoney(const QString& input) {
QString cleanInput = input;
Money result = {0,0};
// remove group separators
QLocale locale = QLocale::system();
cleanInput.remove(locale.groupSeparator());
// convert to money
QStringList parts = cleanInput.split(locale.decimalPoint());
if (parts.count() == 1) {
result.integ = parts[0].toInt();
} else if (parts.count() == 2) {
result.integ = parts[0].toInt();
result.fract = parts[1].toInt() * 10;
} else {
// error, not a number
}
return result;
}
示例3: format
QString BitcoinUnits::format(int unit, qint64 n, int nColorIn,
bool fPlus, bool localized)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
if(!valid(unit, nColorIn))
{
return QString(); // Refuse to format invalid unit
}
QLocale locale = QLocale::c();
QString decimal(".");
if (localized)
{
decimal = QString(locale.decimalPoint());
}
qint64 coin = factor(unit, nColorIn);
int num_decimals = decimals(unit, nColorIn);
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
qint64 remainder = n_abs % coin;
QString quotient_str = QString::number(quotient);
QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
// Right-trim excess zeros after the decimal point
int nTrim = 0;
for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i)
++nTrim;
remainder_str.chop(nTrim);
if (localized)
{
QChar thousands = locale.groupSeparator();
int N(quotient_str.size());
for (int i = 3; i < N; ++i)
{
if (i % 3 == 0)
{
quotient_str.insert(N - i, thousands);
}
}
}
if (n < 0)
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
quotient_str.insert(0, '+');
if (DECIMALS[nColorIn] == 0)
{
// if (remainder != 0)
// {
// printf("Remainder for atomic currency is nonzero: %" PRId64, remainder);
// }
return quotient_str;
}
else
{
if (localized)
{
QChar thousandths(' ');
int N(remainder_str.size());
int j = 0;
for (int i = 3; i < N; ++i)
{
if (i % 3 == 0)
{
remainder_str.insert(i + j, thousandths);
++j;
}
}
}
return quotient_str + decimal + remainder_str;
}
}
示例4: sSave
//.........这里部分代码省略.........
QLocale sampleLocale = generateLocale();
if (_mode == cNew)
{
q.prepare( "INSERT INTO locale "
"( locale_id, locale_code, locale_descrip,"
" locale_lang_id, locale_country_id, "
" locale_dateformat, locale_timeformat, locale_timestampformat,"
" locale_intervalformat, locale_qtyformat,"
" locale_curr_scale,"
" locale_salesprice_scale, locale_purchprice_scale,"
" locale_extprice_scale, locale_cost_scale,"
" locale_qty_scale, locale_qtyper_scale,"
" locale_uomratio_scale, locale_percent_scale, "
" locale_comments, "
" locale_error_color, locale_warning_color,"
" locale_emphasis_color, locale_altemphasis_color,"
" locale_expired_color, locale_future_color) "
"VALUES "
"( :locale_id, :locale_code, :locale_descrip,"
" :locale_lang_id, :locale_country_id,"
" :locale_dateformat, :locale_timeformat, :locale_timestampformat,"
" :locale_intervalformat, :locale_qtyformat,"
" :locale_curr_scale,"
" :locale_salesprice_scale, :locale_purchprice_scale,"
" :locale_extprice_scale, :locale_cost_scale,"
" :locale_qty_scale, :locale_qtyper_scale,"
" :locale_uomratio_scale, :local_percent_scale, "
" :locale_comments,"
" :locale_error_color, :locale_warning_color,"
" :locale_emphasis_color, :locale_altemphasis_color,"
" :locale_expired_color, :locale_future_color);" );
}
else if ( (_mode == cEdit) || (_mode == cCopy) )
q.prepare( "UPDATE locale "
"SET locale_code=:locale_code,"
" locale_descrip=:locale_descrip,"
" locale_lang_id=:locale_lang_id,"
" locale_country_id=:locale_country_id,"
" locale_dateformat=:locale_dateformat,"
" locale_timeformat=:locale_timeformat,"
" locale_timestampformat=:locale_timestampformat,"
" locale_intervalformat=:locale_intervalformat,"
" locale_qtyformat=:locale_qtyformat,"
" locale_curr_scale=:locale_curr_scale,"
" locale_salesprice_scale=:locale_salesprice_scale,"
" locale_purchprice_scale=:locale_purchprice_scale,"
" locale_extprice_scale=:locale_extprice_scale,"
" locale_cost_scale=:locale_cost_scale,"
" locale_qty_scale=:locale_qty_scale,"
" locale_qtyper_scale=:locale_qtyper_scale,"
" locale_uomratio_scale=:locale_uomratio_scale,"
" locale_percent_scale=:locale_percent_scale,"
" locale_comments=:locale_comments,"
" locale_error_color=:locale_error_color,"
" locale_warning_color=:locale_warning_color,"
" locale_emphasis_color=:locale_emphasis_color,"
" locale_altemphasis_color=:locale_altemphasis_color,"
" locale_expired_color=:locale_expired_color,"
" locale_future_color=:locale_future_color "
"WHERE (locale_id=:locale_id);" );
q.bindValue(":locale_id", _localeid);
q.bindValue(":locale_code", _code->text());
q.bindValue(":locale_descrip", _description->text());
q.bindValue(":locale_lang_id", _language->id());
q.bindValue(":locale_country_id", _country->id());
q.bindValue(":locale_curr_scale", _currencyScale->text());
q.bindValue(":locale_salesprice_scale", _salesPriceScale->text());
q.bindValue(":locale_purchprice_scale", _purchPriceScale->text());
q.bindValue(":locale_extprice_scale", _extPriceScale->text());
q.bindValue(":locale_cost_scale", _costScale->text());
q.bindValue(":locale_qty_scale", _qtyScale->text());
q.bindValue(":locale_qtyper_scale", _qtyPerScale->text());
q.bindValue(":locale_uomratio_scale", _uomRatioScale->text());
q.bindValue(":locale_percent_scale", _percentScale->text());
q.bindValue(":locale_comments", _comments->toPlainText());
q.bindValue(":locale_error_color", _error->text());
q.bindValue(":locale_warning_color", _warning->text());
q.bindValue(":locale_emphasis_color", _emphasis->text());
q.bindValue(":locale_altemphasis_color", _alternate->text());
q.bindValue(":locale_expired_color", _expired->text());
q.bindValue(":locale_future_color", _future->text());
q.bindValue(":locale_dateformat", convert(sampleLocale.dateFormat(QLocale::ShortFormat)));
q.bindValue(":locale_timeformat", convert(sampleLocale.timeFormat(QLocale::ShortFormat)));
q.bindValue(":locale_timestampformat",convert(sampleLocale.dateFormat(QLocale::ShortFormat)) +
" " + convert(sampleLocale.timeFormat(QLocale::ShortFormat)));
q.bindValue(":locale_intervalformat", convert(sampleLocale.timeFormat(QLocale::ShortFormat).remove("ap", Qt::CaseInsensitive)));
q.bindValue(":locale_qtyformat", QString(sampleLocale.decimalPoint()) +
QString(sampleLocale.negativeSign()) +
QString(sampleLocale.groupSeparator()));
q.exec();
if (q.lastError().type() != QSqlError::NoError)
{
systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
return;
}
done(_localeid);
}