本文整理汇总了C++中QLocale::setNumberOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::setNumberOptions方法的具体用法?C++ QLocale::setNumberOptions怎么用?C++ QLocale::setNumberOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::setNumberOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createAlbumGroupBox
QGroupBox* MainWindow::createAlbumGroupBox()
{
QGroupBox *box = new QGroupBox(tr("Album"));
albumView = new QTableView;
albumView->setEditTriggers(QAbstractItemView::NoEditTriggers);
albumView->setSortingEnabled(true);
albumView->setSelectionBehavior(QAbstractItemView::SelectRows);
albumView->setSelectionMode(QAbstractItemView::SingleSelection);
albumView->setShowGrid(false);
albumView->verticalHeader()->hide();
albumView->setAlternatingRowColors(true);
albumView->setModel(model);
adjustHeader();
QLocale locale = albumView->locale();
locale.setNumberOptions(QLocale::OmitGroupSeparator);
albumView->setLocale(locale);
connect(albumView, SIGNAL(clicked(QModelIndex)),
this, SLOT(showAlbumDetails(QModelIndex)));
connect(albumView, SIGNAL(activated(QModelIndex)),
this, SLOT(showAlbumDetails(QModelIndex)));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(albumView, 0, 0);
box->setLayout(layout);
return box;
}
示例2: initLocale
void Core::initLocale()
{
QLocale systemLocale = QLocale();
#ifndef Q_OS_MAC
setlocale(LC_NUMERIC, NULL);
#else
setlocale(LC_NUMERIC_MASK, NULL);
#endif
char *separator = localeconv()->decimal_point;
if (QString::fromUtf8(separator) != QChar(systemLocale.decimalPoint())) {
//qDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
// HACK: There is a locale conflict, so set locale to C
// Make sure to override exported values or it won't work
qputenv("LANG", "C");
#ifndef Q_OS_MAC
setlocale(LC_NUMERIC, "C");
#else
setlocale(LC_NUMERIC_MASK, "C");
#endif
systemLocale = QLocale::c();
}
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
}
示例3: 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;
}
示例4: QGroupBox
//---------------------FLOW FUNCTION -----------------------
QGroupBox * Mainwindow::viewadd(QWidget *centralwidget,QString filter)
{
QGroupBox *box = new QGroupBox(centralwidget);
QVBoxLayout *layout = new QVBoxLayout;
RoomView = new QTableView();
RoomView->setEditTriggers(QAbstractItemView::NoEditTriggers);
RoomView->setSelectionBehavior(QAbstractItemView::SelectRows);
RoomView->setSelectionMode(QAbstractItemView::SingleSelection);
RoomView->hideColumn(4);
RoomView->hideColumn(5);
RoomView->setShowGrid(false);
RoomView->verticalHeader()->hide();
RoomView->setAlternatingRowColors(true);
if(filter.isEmpty())
{
RoomView->setModel(modelback(centralwidget));
}
else
{
RoomView->setModel(searchmodel(filter));
}
QLocale locale = RoomView->locale();
locale.setNumberOptions(QLocale::OmitGroupSeparator);
RoomView->setLocale(locale);
layout->addWidget(RoomView,0,0);
box->setLayout(layout);
box->setGeometry(QRect(20, 55, 251, 261));
box->show();
return box;
}
示例5: setLocale
void MainWindowModel::setLocale (QLocale::Language language,
QLocale::Country country)
{
QLocale locale (language,
country);
locale.setNumberOptions(HIDE_GROUP_SEPARATOR);
m_locale = locale;
}
示例6: encodeOTPToken
otp::token::Encoder oathEncoder(uint length)
{
QLocale locale = QLocale::c();
locale.setNumberOptions(QLocale::OmitGroupSeparator);
return otp::token::Encoder([length, locale](const QByteArray& token) -> QString
{
return oath::encodeOTPToken(token, locale, length);
});
}
示例7: schemaTranslate
QString UnitsSchemaImperialDecimal::schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)
{
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
// for imperial user/programmer mind; UnitValue is in internal system, that means
// mm/kg/s. And all combined units have to be calculated from there!
// now do special treatment on all cases seems necessary:
if(unit == Unit::Length){ // Length handling ============================
if(UnitValue < 0.00000254){// smaller then 0.001 thou -> inch and scientific notation
unitString = QString::fromLatin1("in");
factor = 25.4;
//}else if(UnitValue < 2.54){ // smaller then 0.1 inch -> Thou (mil)
// unitString = QString::fromLatin1("thou");
// factor = 0.0254;
}else{ // bigger then 1000 mi -> scientific notation
unitString = QString::fromLatin1("in");
factor = 25.4;
}
}else if (unit == Unit::Area){
// TODO Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^2");
factor = 645.16;
}else if (unit == Unit::Volume){
// TODO Cascade for the Volume
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^3");
factor = 16387.064;
}else if (unit == Unit::Mass){
// TODO Cascade for the wights
// default action for all cases without special treatment:
unitString = QString::fromLatin1("lb");
factor = 0.45359237;
}else if (unit == Unit::Pressure){
if(UnitValue < 145.038){// psi is the smallest
unitString = QString::fromLatin1("psi");
factor = 0.145038;
//}else if(UnitValue < 145038){
// unitString = QString::fromLatin1("ksi");
// factor = 145.038;
}else{ // bigger then 1000 ksi -> psi + scientific notation
unitString = QString::fromLatin1("psi");
factor = 0.145038;
}
}else{
// default action for all cases without special treatment:
unitString = quant.getUnit().getString();
factor = 1.0;
}
//return QString::fromLatin1("%L1 %2").arg(quant.getValue() / factor).arg(unitString);
QLocale Lc = QLocale::system();
Lc.setNumberOptions(Lc.OmitGroupSeparator | Lc.RejectGroupSeparator);
QString Ln = Lc.toString((quant.getValue() / factor), 'f', Base::UnitsApi::getDecimals());
return QString::fromUtf8("%1 %2").arg(Ln).arg(unitString);
}
示例8: toLocale
QString UnitsSchema::toLocale(const Base::Quantity& quant, double factor, const QString& unitString) const
{
//return QString::fromUtf8("%L1 %2").arg(quant.getValue() / factor).arg(unitString);
QLocale Lc = QLocale::system();
const QuantityFormat& format = quant.getFormat();
if (format.option != QuantityFormat::None) {
uint opt = static_cast<uint>(format.option);
Lc.setNumberOptions(static_cast<QLocale::NumberOptions>(opt));
}
QString Ln = Lc.toString((quant.getValue() / factor), format.toFormat(), format.precision);
return QString::fromUtf8("%1 %2").arg(Ln, unitString);
}
示例9: lengthToWidgets
void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
Length const & len, Length::UNIT /*defaultUnit*/)
{
if (len.empty()) {
// no length (UNIT_NONE)
combo->setCurrentItem(Length::defaultUnit());
input->setText("");
} else {
combo->setCurrentItem(len.unit());
QLocale loc;
loc.setNumberOptions(QLocale::OmitGroupSeparator);
input->setText(loc.toString(Length(len).value()));
}
}
示例10: 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(";")));
}
示例11: dateToString
QString DateUtils::dateToString(const double date, int precision){
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if(precision == -1)
precision = MainWindow::getInstance()->getAppSettings().mPrecision;
char fmt = 'f';
if (date>250000){
fmt = 'G';
}
if (std::fabs(date)<1E-10) {
return "0";
}
else
return locale.toString(date, fmt, precision);
}
示例12: slotUpdateDisplay
void ProfilesDialog::slotUpdateDisplay(QString currentProfile)
{
if (askForSave() == false) {
m_view.profiles_list->blockSignals(true);
m_view.profiles_list->setCurrentIndex(m_selectedProfileIndex);
m_view.profiles_list->blockSignals(false);
return;
}
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_selectedProfileIndex = m_view.profiles_list->currentIndex();
if (currentProfile.isEmpty())
currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
m_isCustomProfile = currentProfile.contains('/');
m_view.button_create->setEnabled(true);
m_view.button_delete->setEnabled(m_isCustomProfile);
m_view.properties->setEnabled(m_isCustomProfile);
m_view.button_save->setEnabled(m_isCustomProfile);
QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
m_view.description->setText(values.value("description"));
m_view.size_w->setValue(values.value("width").toInt());
m_view.size_h->setValue(values.value("height").toInt());
m_view.aspect_num->setValue(values.value("sample_aspect_num").toInt());
m_view.aspect_den->setValue(values.value("sample_aspect_den").toInt());
m_view.display_num->setValue(values.value("display_aspect_num").toInt());
m_view.display_den->setValue(values.value("display_aspect_den").toInt());
m_view.frame_num->setValue(values.value("frame_rate_num").toInt());
m_view.frame_den->setValue(values.value("frame_rate_den").toInt());
m_view.progressive->setChecked(values.value("progressive").toInt());
if (values.value("progressive").toInt()) {
m_view.fields->setText(locale.toString((double) values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2));
} else {
m_view.fields->setText(locale.toString((double) 2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2));
}
int colorix = m_view.colorspace->findData(values.value("colorspace").toInt());
if (colorix > -1) m_view.colorspace->setCurrentIndex(colorix);
m_profileIsModified = false;
}
示例13: decimalSeparators
QLocale ImportASCIIDialog::decimalSeparators()
{
QLocale locale;
switch (boxDecimalSeparator->currentIndex()){
case 0:
locale = QLocale::system();
break;
case 1:
locale = QLocale::c();
break;
case 2:
locale = QLocale(QLocale::German);
break;
case 3:
locale = QLocale(QLocale::French);
break;
}
if (d_omit_thousands_sep->isChecked())
locale.setNumberOptions(QLocale::OmitGroupSeparator);
return locale;
}
示例14: main
int main(int argc, char **argv)
{
//See http://doc.qt.io/qt-5/qopenglwidget.html#opengl-function-calls-headers-and-qopenglfunctions
/** Calling QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance is mandatory
on some platforms (for example, OS X) when an OpenGL core profile context is requested. This is to
ensure that resource sharing between contexts stays functional as all internal contexts are created
using the correct version and profile.
**/
{
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
format.setOption(QSurfaceFormat::StereoBuffers, true);
format.setStencilBufferSize(0);
#ifdef CC_GL_WINDOW_USE_QWINDOW
format.setStereo(true);
#endif
#ifdef Q_OS_MAC
format.setStereo(false);
format.setVersion( 2, 1 );
format.setProfile( QSurfaceFormat::CoreProfile );
#endif
#ifdef QT_DEBUG
format.setOption(QSurfaceFormat::DebugContext, true);
#endif
QSurfaceFormat::setDefaultFormat(format);
}
//The 'AA_ShareOpenGLContexts' attribute must be defined BEFORE the creation of the Q(Gui)Application
//DGM: this is mandatory to enable exclusive full screen for ccGLWidget (at least on Windows)
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
//QT initialiation
qccApplication app(argc, argv);
//Locale management
{
//Force 'english' locale so as to get a consistent behavior everywhere
QLocale locale = QLocale(QLocale::English);
locale.setNumberOptions(QLocale::c().numberOptions());
QLocale::setDefault(locale);
#ifdef Q_OS_UNIX
//We reset the numeric locale for POSIX functions
//See http://qt-project.org/doc/qt-5/qcoreapplication.html#locale-settings
setlocale(LC_NUMERIC, "C");
#endif
}
#ifdef USE_VLD
VLDEnable();
#endif
#ifdef Q_OS_MAC
// This makes sure that our "working directory" is not within the application bundle
QDir appDir = QCoreApplication::applicationDirPath();
if ( appDir.dirName() == "MacOS" )
{
appDir.cdUp();
appDir.cdUp();
appDir.cdUp();
QDir::setCurrent( appDir.absolutePath() );
}
#endif
//splash screen
QSplashScreen* splash = 0;
QTime splashStartTime;
//restore some global parameters
{
QSettings settings;
settings.beginGroup(ccPS::GlobalShift());
double maxAbsCoord = settings.value(ccPS::MaxAbsCoord(), ccGlobalShiftManager::MaxCoordinateAbsValue()).toDouble();
double maxAbsDiag = settings.value(ccPS::MaxAbsDiag(), ccGlobalShiftManager::MaxBoundgBoxDiagonal()).toDouble();
settings.endGroup();
ccLog::Print(QString("[Global Shift] Max abs. coord = %1 / max abs. diag = %2").arg(maxAbsCoord, 0, 'e', 0).arg(maxAbsDiag, 0, 'e', 0));
ccGlobalShiftManager::SetMaxCoordinateAbsValue(maxAbsCoord);
ccGlobalShiftManager::SetMaxBoundgBoxDiagonal(maxAbsDiag);
}
//Command line mode?
bool commandLine = (argc > 1 && argv[1][0] == '-');
//specific case: translation file selection
int lastArgumentIndex = 1;
QTranslator translator;
if (commandLine && QString(argv[1]).toUpper() == "-LANG")
{
QString langFilename = QString(argv[2]);
//Load translation file
if (translator.load(langFilename, QCoreApplication::applicationDirPath()))
{
qApp->installTranslator(&translator);
}
else
//.........这里部分代码省略.........
示例15: main
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(caQtDM);
#ifdef MOBILE
Q_INIT_RESOURCE(qtcontrols);
#endif
QApplication app(argc, argv);
QApplication::setOrganizationName("Paul Scherrer Institut");
QApplication::setApplicationName("caQtDM");
#ifdef MOBILE_ANDROID
app.setStyle(QStyleFactory::create("fusion"));
#endif
// we do not want numbers with a group separators
QLocale loc = QLocale::system();
loc.setNumberOptions(QLocale::OmitGroupSeparator);
loc.setDefault(loc);
QString fileName = "";
QString macroString = "";
QString geometry = "";
QString macroFile = "";
QMap<QString, QString> options;
options.clear();
searchFile *s = new searchFile("caQtDM_stylesheet.qss");
QString fileNameFound = s->findFile();
if(fileNameFound.isNull()) {
printf("caQtDM -- file <caQtDM_stylesheet.qss> could not be loaded, is 'CAQTDM_DISPLAY_PATH' <%s> defined?\n", qasc(s->displayPath()));
} else {
QFile file(fileNameFound);
file.open(QFile::ReadOnly);
QString StyleSheet = QLatin1String(file.readAll());
printf("caQtDM -- file <caQtDM_stylesheet.qss> loaded as the default application stylesheet\n");
app.setStyleSheet(StyleSheet);
file.close();
}
int in, numargs;
bool attach = false;
bool minimize= false;
bool nostyles = false;
bool printscreen = false;
bool resizing = true;
for (numargs = argc, in = 1; in < numargs; in++) {
//qDebug() << argv[in];
if ( strcmp (argv[in], "-display" ) == 0 ) {
in++;
printf("caQtDM -- display <%s>\n", argv[in]);
} else if ( strcmp (argv[in], "-macro" ) == 0 ) {
in++;
printf("caQtDM -- macro <%s>\n", argv[in]);
macroString = QString(argv[in]);
} else if ( strcmp (argv[in], "-attach" ) == 0 ) {
printf("caQtDM -- will attach to another caQtDM if running\n");
attach = true;
} else if ( strcmp (argv[in], "-noMsg" ) == 0 ) {
printf("caQtDM -- will minimize its main windows\n");
minimize = true;
} else if( strcmp (argv[in], "-macrodefs" ) == 0) {
in++;
printf("caQtDM -- will load macro string from file <%s>\n", argv[in]);
macroFile = QString(argv[in]);
} else if ( strcmp (argv[in], "-noStyles" ) == 0 ) {
printf("caQtDM -- will not replace the default application stylesheet caQtDM_stylesheet.qss\n");
nostyles = true;
} else if ( strcmp (argv[in], "-x" ) == 0 ) {
} else if ( strcmp (argv[in], "-displayFont" ) == 0 ) {
in++;
} else if(!strcmp(argv[in],"-help") || !strcmp(argv[in],"-h") || !strcmp(argv[in],"-?")) {
in++;
printf("Usage:\n"
" caQtDM[X options]\n"
" [-help | -h | -?]\n"
" [-x]\n"
" [-attach]\n"
" [-noMsg]\n"
" [-noStyles] works only when not attaching\n"
" [-macro \"xxx=aaa,yyy=bbb, ...\"]\n"
" [-macrodefs filename] will load macro definitions from file\n"
" [-dg [<width>x<height>][+<xoffset>-<yoffset>]\n"
" [-httpconfig] will display a network configuration screen at startup\n"
" [-print] will print file and exit\n"
" [-noResize] will prevent resizing\n"
" [-cs defaultcontrolsystempluginname]\n"
" [-option \"xxx=aaa,yyy=bbb, ...\"] options for cs plugins\n"
" [file]\n"
" [&]\n"
"\n"
" -x -displayFont -display are ignored !\n\n");
exit(1);
} else if((!strcmp(argv[in],"-displayGeometry")) || (!strcmp(argv[in],"-dg"))) {
// [-dg [xpos[xypos]][+xoffset[+yoffset]]
in++;
geometry = QString(argv[in]);
} else if(!strcmp(argv[in], "-print")) {
printscreen = true;
//.........这里部分代码省略.........