本文整理汇总了C++中QLocale::standaloneDayName方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::standaloneDayName方法的具体用法?C++ QLocale::standaloneDayName怎么用?C++ QLocale::standaloneDayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::standaloneDayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: standaloneLongDayName
void tst_QDate::standaloneLongDayName() const
{
if (QLocale::system().language() == QLocale::C) {
QCOMPARE(QDate::longDayName(1, QDate::StandaloneFormat), QLatin1String("Monday"));
QCOMPARE(QDate::longDayName(7, QDate::StandaloneFormat), QLatin1String("Sunday"));
}
QLocale locale = QLocale::system();
for(int i = 1; i <= 7; ++i) {
QCOMPARE(QDate::longDayName(i, QDate::StandaloneFormat), locale.standaloneDayName(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);
}