本文整理汇总了C++中QLocale::monthName方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::monthName方法的具体用法?C++ QLocale::monthName怎么用?C++ QLocale::monthName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::monthName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: longMonthName
void tst_QDate::longMonthName() const
{
if (QLocale::system().language() == QLocale::C) {
QCOMPARE(QDate::longMonthName(1), QLatin1String("January"));
QCOMPARE(QDate::longMonthName(8), QLatin1String("August"));
}
QLocale locale = QLocale::system();
for(int i = 1; i <= 12; ++i) {
QCOMPARE(QDate::longMonthName(i), locale.monthName(i, QLocale::LongFormat));
}
}
示例2: localeChanged
void DateFormatsWidget::localeChanged(QLocale locale)
{
setLocale(locale);
QDateTime now = QDateTime::currentDateTime();
shortDateFormat->setText(locale.toString(now.date(), QLocale::ShortFormat));
shortDateFormat->setToolTip(locale.dateFormat(QLocale::ShortFormat));
longDateFormat->setText(locale.toString(now.date(), QLocale::LongFormat));
longDateFormat->setToolTip(locale.dateFormat(QLocale::LongFormat));
shortTimeFormat->setText(locale.toString(now.time(), QLocale::ShortFormat));
shortTimeFormat->setToolTip(locale.timeFormat(QLocale::ShortFormat));
longTimeFormat->setText(locale.toString(now.time(), QLocale::LongFormat));
longTimeFormat->setToolTip(locale.timeFormat(QLocale::LongFormat));
shortDateTimeFormat->setText(locale.toString(now, QLocale::ShortFormat));
shortDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::ShortFormat));
longDateTimeFormat->setText(locale.toString(now, QLocale::LongFormat));
longDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::LongFormat));
amText->setText(locale.amText());
pmText->setText(locale.pmText());
firstDayOfWeek->setText(toString(locale.firstDayOfWeek()));
int mns = monthNamesShort->currentIndex();
int mnl = monthNamesLong->currentIndex();
int smns = standaloneMonthNamesShort->currentIndex();
int smnl = standaloneMonthNamesLong->currentIndex();
int dnl = dayNamesLong->currentIndex();
int dns = dayNamesShort->currentIndex();
int sdnl = standaloneDayNamesLong->currentIndex();
int sdns = standaloneDayNamesShort->currentIndex();
monthNamesShort->clear();
monthNamesLong->clear();
standaloneMonthNamesShort->clear();
standaloneMonthNamesLong->clear();
dayNamesLong->clear();
dayNamesShort->clear();
standaloneDayNamesLong->clear();
standaloneDayNamesShort->clear();
for (int i = 1; i <= 12; ++i)
monthNamesShort->addItem(locale.monthName(i, QLocale::ShortFormat));
monthNamesShort->setCurrentIndex(mns >= 0 ? mns : 0);
for (int i = 1; i <= 12; ++i)
monthNamesLong->addItem(locale.monthName(i, QLocale::LongFormat));
monthNamesLong->setCurrentIndex(mnl >= 0 ? mnl : 0);
for (int i = 1; i <= 12; ++i)
standaloneMonthNamesShort->addItem(locale.standaloneMonthName(i, QLocale::ShortFormat));
standaloneMonthNamesShort->setCurrentIndex(smns >= 0 ? smns : 0);
for (int i = 1; i <= 12; ++i)
standaloneMonthNamesLong->addItem(locale.standaloneMonthName(i, QLocale::LongFormat));
standaloneMonthNamesLong->setCurrentIndex(smnl >= 0 ? smnl : 0);
for (int i = 1; i <= 7; ++i)
dayNamesLong->addItem(locale.dayName(i, QLocale::LongFormat));
dayNamesLong->setCurrentIndex(dnl >= 0 ? dnl : 0);
for (int i = 1; i <= 7; ++i)
dayNamesShort->addItem(locale.dayName(i, QLocale::ShortFormat));
dayNamesShort->setCurrentIndex(dns >= 0 ? dns : 0);
for (int i = 1; i <= 7; ++i)
standaloneDayNamesLong->addItem(locale.standaloneDayName(i, QLocale::LongFormat));
standaloneDayNamesLong->setCurrentIndex(sdnl >= 0 ? sdnl : 0);
for (int i = 1; i <= 7; ++i)
standaloneDayNamesShort->addItem(locale.standaloneDayName(i, QLocale::ShortFormat));
standaloneDayNamesShort->setCurrentIndex(sdns >= 0 ? sdns : 0);
}
示例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 );
//.........这里部分代码省略.........