当前位置: 首页>>代码示例>>C++>>正文


C++ Global::getDateFormats方法代码示例

本文整理汇总了C++中Global::getDateFormats方法的典型用法代码示例。如果您正苦于以下问题:C++ Global::getDateFormats方法的具体用法?C++ Global::getDateFormats怎么用?C++ Global::getDateFormats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Global的用法示例。


在下文中一共展示了Global::getDateFormats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QWidget

LocalePreferences::LocalePreferences(QWidget *parent) :
    QWidget(parent)
{
    mainLayout = new QGridLayout(this);
    mainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    setLayout(mainLayout);
    QDate date = QDate::currentDate();
    QTime time = QTime::currentTime();

    translationLabel = new QLabel("Language *");
    translationLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
    translationCombo = new QComboBox(this);
    translationCombo->addItem(tr("<System Default>"), QLocale::system().name());
    translationCombo->addItem(tr("Catalan"), "ca");
    translationCombo->addItem(tr("Czech"), "cs_CZ");
    translationCombo->addItem(tr("Danish"), "da");
    translationCombo->addItem(tr("German"), "de");
    translationCombo->addItem(tr("English (US)"), "en_US");
    translationCombo->addItem(tr("English (UK)"), "en_GB");
    translationCombo->addItem(tr("Spanish"), "es");
    translationCombo->addItem(tr("French"), "fr");
    translationCombo->addItem(tr("Japanese"), "ja");
    translationCombo->addItem(tr("Polish"), "pl");
    translationCombo->addItem(tr("Portugese"), "pt");
    translationCombo->addItem(tr("Russian"), "ru");
    translationCombo->addItem(tr("Slovak"), "sk");
    translationCombo->addItem(tr("Chinese"), "zh_CN");
    translationCombo->addItem(tr("Chinese (Taiwan)"), "zh_TW");
    QLabel *restartLabel = new QLabel(tr("*Note: Restart required"),this);


    dateFormatLabel = new QLabel(tr("Date Format"), this);
    dateFormatLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
    dateFormatCombo = new QComboBox(this);
    const QStringList dateFormats = global.getDateFormats();
    for (int i = 0; i < dateFormats.size(); i++) {
        const QString fmt = dateFormats.at(i);
        dateFormatCombo->addItem(fmt + QStringLiteral(" - ") + date.toString(fmt), i + 1);
    }


    timeFormatLabel = new QLabel(tr("Time Format"), this);
    timeFormatLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
    timeFormatCombo = new QComboBox(this);
    const QStringList timeFormats = global.getTimeFormats();
    for (int i = 0; i < timeFormats.size(); i++) {
        const QString fmt = timeFormats.at(i);
        timeFormatCombo->addItem(fmt + QStringLiteral(" - ") + time.toString(fmt), i + 1);
    }

    mainLayout->addWidget(translationLabel,0,0);
    mainLayout->addWidget(translationCombo,0,1);
    mainLayout->addWidget(dateFormatLabel,1,0);
    mainLayout->addWidget(dateFormatCombo,1,1);
    mainLayout->addWidget(timeFormatLabel,2,0);
    mainLayout->addWidget(timeFormatCombo,2,1);
    mainLayout->addWidget(restartLabel,3,0);

    global.settings->beginGroup(INI_GROUP_LOCALE);
    QString translationi = global.settings->value("translation", "").toString();
    int datei = global.settings->value("dateFormat", 1).toInt();
    int timei = global.settings->value("timeFormat", 1).toInt();
    global.settings->endGroup();

    int index = dateFormatCombo->findData(datei);
    dateFormatCombo->setCurrentIndex(index);

    index = timeFormatCombo->findData(timei);
    timeFormatCombo->setCurrentIndex(index);

    index = translationCombo->findData(translationi);
    translationCombo->setCurrentIndex(index);
    this->setFont(global.getGuiFont(font()));
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:74,代码来源:localepreferences.cpp


注:本文中的Global::getDateFormats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。