本文整理汇总了C++中QLocale类的典型用法代码示例。如果您正苦于以下问题:C++ QLocale类的具体用法?C++ QLocale怎么用?C++ QLocale使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLocale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locale
void GridSettingsDialog::updateInternalRepresentation() noexcept {
QLocale locale; // this loads the application's default locale (defined in
// WSI_AppLocale)
mUi->lblIntervalNm->setText(QString("%1 nm").arg(
locale.toString(mCurrentGrid.getInterval()->toNm())));
}
示例2: QDialog
PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) :
QDialog(parent),
ui(new Ui::PreferencesDialog),
profile(_profile)
{
ui->setupUi(this);
channeltype.clear();
channeltype[schema::FLAG] = tr("Flag");
channeltype[schema::MINOR_FLAG] = tr("Minor Flag");
channeltype[schema::SPAN] = tr("Span");
channeltype[schema::UNKNOWN] = tr("Always Minor");
//#ifdef LOCK_RESMED_SESSIONS
// QList<Machine *> machines = p_profile->GetMachines(MT_CPAP);
// for (QList<Machine *>::iterator it = machines.begin(); it != machines.end(); ++it) {
// const QString & mclass=(*it)->loaderName();
// if (mclass == STR_MACH_ResMed) {
// ui->combineSlider->setEnabled(false);
// ui->IgnoreSlider->setEnabled(false);
// ui->timeEdit->setEnabled(false);
// break;
// }
// }
//#endif
QLocale locale = QLocale::system();
QString shortformat = locale.dateFormat(QLocale::ShortFormat);
if (!shortformat.toLower().contains("yyyy")) {
shortformat.replace("yy", "yyyy");
}
// Qt::DayOfWeek dow = firstDayOfWeekFromLocale();
// QTextCharFormat format = ui->startedUsingMask->calendarWidget()->weekdayTextFormat(Qt::Saturday);
// format.setForeground(QBrush(Qt::black, Qt::SolidPattern));
Q_ASSERT(profile != nullptr);
ui->tabWidget->setCurrentIndex(0);
//i=ui->timeZoneCombo->findText((*profile)["TimeZone"].toString());
//ui->timeZoneCombo->setCurrentIndex(i);
ui->showLeakRedline->setChecked(profile->cpap->showLeakRedline());
ui->leakRedlineSpinbox->setValue(profile->cpap->leakRedline());
ui->oxiDesaturationThreshold->setValue(schema::channel[OXI_SPO2].lowerThreshold());
ui->flagPulseAbove->setValue(schema::channel[OXI_Pulse].upperThreshold());
ui->flagPulseBelow->setValue(schema::channel[OXI_Pulse].lowerThreshold());
ui->spo2Drop->setValue(profile->oxi->spO2DropPercentage());
ui->spo2DropTime->setValue(profile->oxi->spO2DropDuration());
ui->pulseChange->setValue(profile->oxi->pulseChangeBPM());
ui->pulseChangeTime->setValue(profile->oxi->pulseChangeDuration());
ui->oxiDiscardThreshold->setValue(profile->oxi->oxiDiscardThreshold());
ui->eventIndexCombo->setCurrentIndex(profile->general->calculateRDI() ? 1 : 0);
ui->automaticImport->setChecked(profile->cpap->autoImport());
ui->timeEdit->setTime(profile->session->daySplitTime());
int val = profile->session->combineCloseSessions();
ui->combineSlider->setValue(val);
if (val > 0) {
ui->combineLCD->display(val);
} else { ui->combineLCD->display(STR_TR_Off); }
val = profile->session->ignoreShortSessions();
ui->IgnoreSlider->setValue(val);
if (val > 0) {
ui->IgnoreLCD->display(val);
} else { ui->IgnoreLCD->display(STR_TR_Off); }
ui->LockSummarySessionSplitting->setChecked(profile->session->lockSummarySessions());
ui->applicationFont->setCurrentFont(QApplication::font());
//ui->applicationFont->setFont(QApplication::font());
ui->applicationFontSize->setValue(QApplication::font().pointSize());
ui->applicationFontBold->setChecked(QApplication::font().weight() == QFont::Bold);
ui->applicationFontItalic->setChecked(QApplication::font().italic());
ui->graphFont->setCurrentFont(*defaultfont);
//ui->graphFont->setFont(*defaultfont);
ui->graphFontSize->setValue(defaultfont->pointSize());
ui->graphFontBold->setChecked(defaultfont->weight() == QFont::Bold);
ui->graphFontItalic->setChecked(defaultfont->italic());
ui->titleFont->setCurrentFont(*mediumfont);
//ui->titleFont->setFont(*mediumfont);
ui->titleFontSize->setValue(mediumfont->pointSize());
ui->titleFontBold->setChecked(mediumfont->weight() == QFont::Bold);
ui->titleFontItalic->setChecked(mediumfont->italic());
ui->bigFont->setCurrentFont(*bigfont);
//ui->bigFont->setFont(*bigfont);
ui->bigFontSize->setValue(bigfont->pointSize());
ui->bigFontBold->setChecked(bigfont->weight() == QFont::Bold);
ui->bigFontItalic->setChecked(bigfont->italic());
//.........这里部分代码省略.........
示例3: EVentana
EResumen::EResumen( QWidget *parent, tipo que )
: EVentana( parent )
{
setObjectName( "selectorResumen" );
setWindowTitle( "Seleccione el Resumen" );
setAttribute( Qt::WA_DeleteOnClose );
generar = que;
QVBoxLayout *layoutPrincipal = new QVBoxLayout( this );
layoutPrincipal->setMargin( 3 );
layoutPrincipal->setSpacing( 3 );
switch( que )
{
case diario:
{
QGroupBox *g = new QGroupBox( this );
g->setTitle( "Elija la fecha del resumen" );
g->setAlignment( Qt::AlignHCenter );
g->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
QVBoxLayout *v = new QVBoxLayout( g );
CWfecha = new QCalendarWidget( g );
CWfecha->setGridVisible( false );
CWfecha->setMaximumDate( QDate::currentDate() );
CWfecha->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
v->addWidget( CWfecha );
g->adjustSize();
layoutPrincipal->addWidget( g );
break;
}
case mensual:
{
QGroupBox *groupBox = new QGroupBox( this );
groupBox->setObjectName(QString::fromUtf8("groupBox"));
groupBox->setTitle( "Elija el mes para el resumen" );
groupBox->setAlignment( Qt::AlignCenter );
groupBox->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
QVBoxLayout *v = new QVBoxLayout(groupBox);
v->setObjectName( "vLayout" );
QHBoxLayout *h1 = new QHBoxLayout();
h1->setObjectName("hLayout1");
QLabel *Lmes = new QLabel(groupBox);
Lmes->setObjectName(QString::fromUtf8("labelMes"));
Lmes->setText( tr( "Mes:" ) );
h1->addWidget(Lmes);
CBMes = new QComboBox(groupBox);
CBMes->setObjectName(QString::fromUtf8("CBMes"));
// Inserto los meses
QLocale locale;
for( int i = 1; i<=12; i++ )
{
CBMes->insertItem( i, locale.monthName( i ) );
}
CBMes->setCurrentIndex( QDate::currentDate().month() );
h1->addWidget(CBMes);
v->addLayout(h1);
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
QLabel *Lano = new QLabel(groupBox);
Lano->setObjectName(QString::fromUtf8("lano"));
Lano->setText( tr( "Año:" ) );
horizontalLayout_2->addWidget(Lano);
SBAno = new QSpinBox(groupBox);
SBAno->setObjectName(QString::fromUtf8("SBAno"));
SBAno->setMaximum( QDate::currentDate().year() );
SBAno->setSingleStep( 1 );
SBAno->setValue( QDate::currentDate().year() );
horizontalLayout_2->addWidget(SBAno);
v->addLayout(horizontalLayout_2);
layoutPrincipal->addWidget( groupBox );
break;
}
case anual:
{
QHBoxLayout *layout = new QHBoxLayout( this );
QLabel *etiqueta = new QLabel( this );
etiqueta->setText( QString( "Año:" ) );
seleccion = new QSpinBox( this );
seleccion->setRange( 0, QDate::currentDate().year() );
seleccion->setSingleStep( 1 );
seleccion->setValue( QDate::currentDate().year() );
layout->addWidget( etiqueta );
layout->addWidget( seleccion );
layoutPrincipal->addLayout( layout );
break;
}
case semanal:
{
QGroupBox *g = new QGroupBox( this );
g->setTitle( "Elija un dia de la semana para el resumen" );
g->setAlignment( Qt::AlignHCenter );
//.........这里部分代码省略.........
示例4: DROP_EMPTY_PLACEHOLDER
// update the dive and return the notes field, stripped of the HTML junk
void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes,
QString startpressure, QString endpressure, QString gasmix)
{
#define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) (_s).clear()
DROP_EMPTY_PLACEHOLDER(location);
DROP_EMPTY_PLACEHOLDER(duration);
DROP_EMPTY_PLACEHOLDER(depth);
DROP_EMPTY_PLACEHOLDER(airtemp);
DROP_EMPTY_PLACEHOLDER(watertemp);
DROP_EMPTY_PLACEHOLDER(suit);
DROP_EMPTY_PLACEHOLDER(buddy);
DROP_EMPTY_PLACEHOLDER(diveMaster);
DROP_EMPTY_PLACEHOLDER(weight);
DROP_EMPTY_PLACEHOLDER(gasmix);
DROP_EMPTY_PLACEHOLDER(startpressure);
DROP_EMPTY_PLACEHOLDER(endpressure);
DROP_EMPTY_PLACEHOLDER(notes);
#undef DROP_EMPTY_PLACEHOLDER
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
// notes comes back as rich text - let's convert this into plain text
QTextDocument doc;
doc.setHtml(notes);
notes = doc.toPlainText();
if (!d) {
qDebug() << "don't touch this... no dive";
return;
}
bool diveChanged = false;
bool needResort = false;
invalidate_dive_cache(d);
if (date != get_dive_date_string(d->when)) {
diveChanged = needResort = true;
QDateTime newDate;
// what a pain - Qt will not parse dates if the day of the week is incorrect
// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
// we need to make sure we don't try to parse that
QString format(QString(prefs.date_format) + QChar(' ') + prefs.time_format);
if (format.contains(QLatin1String("ddd")) || format.contains(QLatin1String("dddd"))) {
QString dateFormatToDrop = format.contains(QLatin1String("ddd")) ? QStringLiteral("ddd") : QStringLiteral("dddd");
QDateTime ts;
QLocale loc = getLocale();
ts.setMSecsSinceEpoch(d->when * 1000L);
QString drop = loc.toString(ts.toUTC(), dateFormatToDrop);
format.replace(dateFormatToDrop, "");
date.replace(drop, "");
}
newDate = QDateTime::fromString(date, format);
if (!newDate.isValid()) {
qDebug() << "unable to parse date" << date << "with the given format" << format;
QRegularExpression isoDate("\\d+-\\d+-\\d+[^\\d]+\\d+:\\d+");
if (date.contains(isoDate)) {
newDate = QDateTime::fromString(date, "yyyy-M-d h:m:s");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date, "yy-M-d h:m:s");
if (newDate.isValid())
goto parsed;
}
QRegularExpression isoDateNoSecs("\\d+-\\d+-\\d+[^\\d]+\\d+");
if (date.contains(isoDateNoSecs)) {
newDate = QDateTime::fromString(date, "yyyy-M-d h:m");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date, "yy-M-d h:m");
if (newDate.isValid())
goto parsed;
}
QRegularExpression usDate("\\d+/\\d+/\\d+[^\\d]+\\d+:\\d+:\\d+");
if (date.contains(usDate)) {
newDate = QDateTime::fromString(date, "M/d/yyyy h:m:s");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date, "M/d/yy h:m:s");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date.toLower(), "M/d/yyyy h:m:sap");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date.toLower(), "M/d/yy h:m:sap");
if (newDate.isValid())
goto parsed;
}
QRegularExpression usDateNoSecs("\\d+/\\d+/\\d+[^\\d]+\\d+:\\d+");
if (date.contains(usDateNoSecs)) {
newDate = QDateTime::fromString(date, "M/d/yyyy h:m");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date, "M/d/yy h:m");
if (newDate.isValid())
goto parsed;
newDate = QDateTime::fromString(date.toLower(), "M/d/yyyy h:map");
if (newDate.isValid())
goto parsed;
//.........这里部分代码省略.........
示例5: line
void PrettyItemDelegate::paintBody( QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index ) const {
painter->save();
painter->translate( option.rect.topLeft() );
QRectF line(0, 0, option.rect.width(), option.rect.height());
if (downloadInfo) line.setWidth(line.width() / 2);
painter->setClipRect(line);
const bool isActive = index.data( ActiveTrackRole ).toBool();
const bool isSelected = option.state & QStyle::State_Selected;
// draw the "current track" highlight underneath the text
if (isActive && !isSelected) {
paintActiveOverlay(painter, line.x(), line.y(), line.width(), line.height());
}
// get the video metadata
const VideoPointer videoPointer = index.data( VideoRole ).value<VideoPointer>();
const Video *video = videoPointer.data();
// thumb
if (!video->thumbnail().isNull()) {
painter->drawImage(QRect(0, 0, THUMB_WIDTH, THUMB_HEIGHT), video->thumbnail());
// play icon overlayed on the thumb
if (isActive)
paintPlayIcon(painter);
// time
QString timeString;
int duration = video->duration();
if ( duration > 3600 )
timeString = QTime().addSecs(duration).toString("h:mm:ss");
else
timeString = QTime().addSecs(duration).toString("m:ss");
drawTime(painter, timeString, line);
}
if (isActive) painter->setFont(boldFont);
// text color
if (isSelected)
painter->setPen(QPen(option.palette.brush(QPalette::HighlightedText), 0));
else
painter->setPen(QPen(option.palette.brush(QPalette::Text), 0));
// title
QString videoTitle = video->title();
QRectF textBox = line.adjusted(PADDING+THUMB_WIDTH, PADDING, -2 * PADDING, -PADDING);
textBox = painter->boundingRect( textBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, videoTitle);
painter->drawText(textBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, videoTitle);
painter->setFont(smallerFont);
// published date
QString publishedString = video->published().date().toString(Qt::DefaultLocaleShortDate);
QSizeF stringSize(QFontMetrics(painter->font()).size( Qt::TextSingleLine, publishedString ) );
QPointF textLoc(PADDING+THUMB_WIDTH, PADDING*2 + textBox.height());
QRectF publishedTextBox(textLoc , stringSize);
painter->drawText(publishedTextBox, Qt::AlignLeft | Qt::AlignTop, publishedString);
// author
bool authorHovered = false;
bool authorPressed = false;
const bool isHovered = index.data(HoveredItemRole).toBool();
if (isHovered) {
authorHovered = index.data(AuthorHoveredRole).toBool();
authorPressed = index.data(AuthorPressedRole).toBool();
}
painter->save();
painter->setFont(smallerBoldFont);
if (!isSelected) {
if (authorHovered)
painter->setPen(QPen(option.palette.brush(QPalette::Highlight), 0));
else
painter->setPen(QPen(option.palette.brush(QPalette::Mid), 0));
}
QString authorString = video->author();
textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
stringSize = QSizeF(QFontMetrics(painter->font()).size( Qt::TextSingleLine, authorString ) );
QRectF authorTextBox(textLoc , stringSize);
authorRects.insert(index.row(), authorTextBox.toRect());
painter->drawText(authorTextBox, Qt::AlignLeft | Qt::AlignTop, authorString);
painter->restore();
// view count
if (video->viewCount() >= 0) {
painter->save();
QLocale locale;
QString viewCountString = tr("%1 views").arg(locale.toString(video->viewCount()));
textLoc.setX(textLoc.x() + stringSize.width() + PADDING);
stringSize = QSizeF(QFontMetrics(painter->font()).size( Qt::TextSingleLine, viewCountString ) );
QRectF viewCountTextBox(textLoc , stringSize);
painter->drawText(viewCountTextBox, Qt::AlignLeft | Qt::AlignBottom, viewCountString);
//.........这里部分代码省略.........
示例6: init_ui
void init_ui(int *argcp, char ***argvp)
{
QVariant v;
application = new QApplication(*argcp, *argvp);
// tell Qt to use system proxies
// note: on Linux, "system" == "environment variables"
QNetworkProxyFactory::setUseSystemConfiguration(true);
#if QT_VERSION < 0x050000
// ask QString in Qt 4 to interpret all char* as UTF-8,
// like Qt 5 does.
// 106 is "UTF-8", this is faster than lookup by name
// [http://www.iana.org/assignments/character-sets/character-sets.xml]
QTextCodec::setCodecForCStrings(QTextCodec::codecForMib(106));
#endif
QCoreApplication::setOrganizationName("Subsurface");
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
QCoreApplication::setApplicationName("Subsurface");
// find plugins installed in the application directory (without this SVGs don't work on Windows)
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
xslt_path = strdup(getSubsurfaceDataPath("xslt").toAscii().data());
QLocale loc;
QString uiLang = loc.uiLanguages().first();
// there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info
if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) {
QLocale loc2(loc.bcp47Name());
loc = loc2;
uiLang = loc2.uiLanguages().first();
}
// we don't have translations for English - if we don't check for this
// Qt will proceed to load the second language in preference order - not what we want
// on Linux this tends to be en-US, but on the Mac it's just en
if (!uiLang.startsWith("en")) {
qtTranslator = new QTranslator;
if (qtTranslator->load(loc,"qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
application->installTranslator(qtTranslator);
} else {
qDebug() << "can't find Qt localization for locale" << uiLang <<
"searching in" << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
}
ssrfTranslator = new QTranslator;
if (ssrfTranslator->load(loc,"subsurface", "_") ||
ssrfTranslator->load(loc,"subsurface", "_", getSubsurfaceDataPath("translations")) ||
ssrfTranslator->load(loc,"subsurface", "_", getSubsurfaceDataPath("../translations"))) {
application->installTranslator(ssrfTranslator);
} else {
qDebug() << "can't find Subsurface localization for locale" << uiLang;
}
}
QSettings s;
s.beginGroup("DiveComputer");
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
default_dive_computer_product = getSetting(s,"dive_computer_product");
default_dive_computer_device = getSetting(s, "dive_computer_device");
s.endGroup();
window = new MainWindow();
window->show();
if (existing_filename && existing_filename[0] != '\0')
window->setTitle(MWTF_FILENAME);
else
window->setTitle(MWTF_DEFAULT);
return;
}
示例7: main
int main(int argc, char *argv[]) {
// This should be run as root since libparted requires it.
if (getuid()) {
// trying to obtain root UID
setuid(0);
if (getuid()) {
string args;
for (int i=1; i<argc; ++i) {
args += string(argv[i]) + " ";
}
// Check if we can run via sudo
if (system("[ \"`sudo -l | grep " + string(argv[0]) + " | grep NOPASSWD`\" = \"\" ]")) return system("sudo " + string(argv[0]) + " " + args);
else return system("xdg-su -c \"" + string(argv[0]) + " " + args + "\"");
}
}
if (FileExists("/var/run/guisetup_exec.pid")) {
string pid_locked = ReadFile("/var/run/guisetup_exec.pid").c_str();
if (isProcessRunning(pid_locked)) {
fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str());
return 1;
}
}
pid_t pid = getpid();
if (FileExists("/var/run/guisetup.pid")) {
string pid_locked = ReadFile("/var/run/guisetup.pid").c_str();
if (isProcessRunning(pid_locked)) {
fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str());
return 1;
}
}
WriteFile("/var/run/guisetup.pid", IntToStr(pid));
setlocale(LC_ALL, "");
bindtextdomain( "mpkg", "/usr/share/locale");
textdomain("mpkg");
// For mpkg, note that we copy config to temp directory
CONFIG_FILE="/tmp/mpkg.xml";
mConfig.configName=CONFIG_FILE;
unlink("/tmp/packages.db");
unlink("/tmp/mpkg.xml");
if (!FileExists("/usr/share/setup/packages.db")) {
mError("Oops, no database template in /usr/share/setup/packages.db!");
return 1;
}
if (!FileExists("/usr/share/setup/mpkg-setup.xml")) {
mError("Oops, no config template in /usr/share/setup/mpkg-setup.xml!");
return 1;
}
system("cp /usr/share/setup/packages.db /tmp/packages.db");
system("cp /usr/share/setup/mpkg-setup.xml /tmp/mpkg.xml");
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QApplication a(argc, argv);
QLocale lc;
QTranslator translator;
translator.load("guisetup_" + lc.name(), "/usr/share/setup/l10n");
a.installTranslator(&translator);
MainWindow w;
w.show();
return a.exec();
}
示例8: 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.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);
#endif
QSurfaceFormat::setDefaultFormat(format);
}
ccApplication a(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
if (!QGLFormat::hasOpenGL())
{
QMessageBox::critical(0, "Error", "This application needs OpenGL to run!");
return EXIT_FAILURE;
}
if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) == 0)
{
QMessageBox::critical(0, "Error", "This application needs OpenGL 2.1 at least to run!");
return EXIT_FAILURE;
}
//common data initialization
ccTimer::Init();
FileIOFilter::InitInternalFilters(); //load all known I/O filters (plugins will come later!)
ccNormalVectors::GetUniqueInstance(); //force pre-computed normals array initialization
ccColorScalesManager::GetUniqueInstance(); //force pre-computed color tables initialization
ccViewer w/*(0,Qt::Window|Qt::CustomizeWindowHint)*/;
#ifdef Q_OS_MAC
a.setViewer( &w );
#endif
//register minimal logger to display errors
ccViewerLog logger(&w);
ccLog::RegisterInstance(&logger);
w.show();
//files to open are passed as argument
if (argc > 1)
{
//parse arguments
QStringList filenames;
int i = 1;
while ( i < argc)
{
QString argument = QString(argv[i++]).toUpper();
//Argument '-WIN X Y W H' (to set window size and position)
if (argument.toUpper() == "-WIN")
//.........这里部分代码省略.........
示例9: data
void tst_QLocale::toUpper_QLocale_2()
{
QString s = data();
QLocale l;
QBENCHMARK { LOOP(l.toUpper(s)) }
}
示例10: timeFormat
QString QtPropertyBrowserUtils::timeFormat()
{
QLocale loc;
// ShortFormat is missing seconds on UNIX.
return loc.timeFormat(QLocale::LongFormat);
}
示例11: memoryErrorMessage
void FFT::fftCurve()
{
int n2 = d_n/2;
double *amp = (double *)malloc(d_n*sizeof(double));
double *result = (double *)malloc(2*d_n*sizeof(double));
if(!amp || !result){
memoryErrorMessage();
return;
}
double df = 1.0/(double)(d_n*d_sampling);//frequency sampling
double aMax = 0.0;//max amplitude
if(!d_inverse){
gsl_fft_real_workspace *work = gsl_fft_real_workspace_alloc(d_n);
gsl_fft_real_wavetable *real = gsl_fft_real_wavetable_alloc(d_n);
if(!work || !real){
memoryErrorMessage();
return;
}
gsl_fft_real_transform(d_y, 1, d_n, real, work);
gsl_fft_halfcomplex_unpack (d_y, result, 1, d_n);
gsl_fft_real_wavetable_free(real);
gsl_fft_real_workspace_free(work);
} else {
gsl_fft_real_unpack (d_y, result, 1, d_n);
gsl_fft_complex_wavetable *wavetable = gsl_fft_complex_wavetable_alloc (d_n);
gsl_fft_complex_workspace *workspace = gsl_fft_complex_workspace_alloc (d_n);
if(!workspace || !wavetable){
memoryErrorMessage();
return;
}
gsl_fft_complex_inverse (result, 1, d_n, wavetable, workspace);
gsl_fft_complex_wavetable_free (wavetable);
gsl_fft_complex_workspace_free (workspace);
}
if (d_shift_order){
for(int i = 0; i < d_n; i++){
d_x[i] = (i - n2)*df;
int j = i + d_n;
double aux = result[i];
result[i] = result[j];
result[j] = aux;
}
} else {
for(int i = 0; i < d_n; i++)
d_x[i] = i*df;
}
for(int i = 0; i < d_n; i++) {
int i2 = 2*i;
double real_part = result[i2];
double im_part = result[i2+1];
double a = sqrt(real_part*real_part + im_part*im_part);
amp[i]= a;
if (a > aMax)
aMax = a;
}
ApplicationWindow *app = (ApplicationWindow *)parent();
QLocale locale = app->locale();
int prec = app->d_decimal_digits;
for (int i = 0; i < d_n; i++){
int i2 = 2*i;
d_result_table->setText(i, 0, locale.toString(d_x[i], 'g', prec));
d_result_table->setText(i, 1, locale.toString(result[i2], 'g', prec));
d_result_table->setText(i, 2, locale.toString(result[i2 + 1], 'g', prec));
if (d_normalize)
d_result_table->setText(i, 3, locale.toString(amp[i]/aMax, 'g', prec));
else
d_result_table->setText(i, 3, locale.toString(amp[i], 'g', prec));
d_result_table->setText(i, 4, locale.toString(atan(result[i2 + 1]/result[i2]), 'g', prec));
}
free(amp);
free(result);
}
示例12: dateFormat
QString QtPropertyBrowserUtils::dateFormat()
{
QLocale loc;
return loc.dateFormat(QLocale::ShortFormat);
}
示例13: isChinese
bool Utils::isChinese()
{
QLocale locale;
return locale.language() == QLocale::Chinese;
}
示例14: displayText
QString DateTimeDelegate::displayText(const QVariant &value, const QLocale &locale) const
{
if (m_IsDateOnly)
return locale.toString(value.toDate(), tkTr(Trans::Constants::DATEFORMAT_FOR_EDITOR));
return locale.toString(value.toDateTime(), tkTr(Trans::Constants::DATETIMEFORMAT_FOR_EDITOR));
}
示例15: 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.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
QDir workingDir = QCoreApplication::applicationDirPath();
#ifdef Q_OS_MAC
// This makes sure that our "working directory" is not within the application bundle
if ( workingDir.dirName() == "MacOS" )
{
workingDir.cdUp();
workingDir.cdUp();
workingDir.cdUp();
}
#endif
//store the log message until a valid logging instance is registered
ccLog::EnableMessageBackup(true);
//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 commands
int lastArgumentIndex = 1;
QTranslator translator;
if (commandLine)
{
//translation file selection
if (QString(argv[lastArgumentIndex]).toUpper() == "-LANG")
{
QString langFilename = QString(argv[2]);
//Load translation file
if (translator.load(langFilename, QCoreApplication::applicationDirPath()))
{
qApp->installTranslator(&translator);
}
else
{
//.........这里部分代码省略.........