本文整理汇总了C++中DateAndTime::hour方法的典型用法代码示例。如果您正苦于以下问题:C++ DateAndTime::hour方法的具体用法?C++ DateAndTime::hour怎么用?C++ DateAndTime::hour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateAndTime
的用法示例。
在下文中一共展示了DateAndTime::hour方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPreviousValue
/** Set a value for a widget.
*
* The function needs to know about the types of widgets
* that are being used. Currently it knows about QComboBox, QLineEdit and
* QCheckBox
* @param widget :: A pointer to the widget
* @param propName :: The property name
*/
void AlgorithmDialog::setPreviousValue(QWidget *widget,
const QString &propName) {
// If is called from a script, check if we have such property
if (isForScript() && !getAlgorithmProperty(propName))
return;
QString value = getPreviousValue(propName);
Mantid::Kernel::Property *property = getAlgorithmProperty(propName);
// Do the right thing for the widget type
if (QComboBox *opts = qobject_cast<QComboBox *>(widget)) {
if (property && value.isEmpty()) {
value = QString::fromStdString(property->value());
}
int index = opts->findText(value);
if (index >= 0) {
opts->setCurrentIndex(index);
}
return;
}
if (QAbstractButton *checker = qobject_cast<QAbstractButton *>(widget)) {
if (value.isEmpty() &&
dynamic_cast<Mantid::Kernel::PropertyWithValue<bool> *>(property))
value = QString::fromStdString(property->value());
checker->setChecked(value != "0");
return;
}
if (QDateTimeEdit *dateEdit = qobject_cast<QDateTimeEdit *>(widget)) {
// String in ISO8601 format
DateAndTime t = DateAndTime::getCurrentTime();
try {
t.setFromISO8601(verifyAndSanitizeISO8601(value.toStdString()));
} catch (std::exception &) {
}
dateEdit->setDate(QDate(t.year(), t.month(), t.day()));
dateEdit->setTime(QTime(t.hour(), t.minute(), t.second(), 0));
return;
}
QLineEdit *textfield = qobject_cast<QLineEdit *>(widget);
MantidWidget *mtdwidget = qobject_cast<MantidWidget *>(widget);
if (textfield || mtdwidget) {
if (!isForScript()) {
if (textfield)
textfield->setText(value);
else
mtdwidget->setUserInput(value);
} else {
// Need to check if this is the default value as we don't fill them in if
// they are
if (m_python_arguments.contains(propName) || !property->isDefault()) {
if (textfield)
textfield->setText(value);
else
mtdwidget->setUserInput(value);
}
}
return;
}
PropertyWidget *propWidget = qobject_cast<PropertyWidget *>(widget);
if (propWidget) {
propWidget->setPreviousValue(value);
return;
}
// Reaching here means we have a widget type we don't understand. Tell the
// developer
QMessageBox::warning(
this, windowTitle(),
QString("Cannot set value for ") + widget->metaObject()->className() +
". Update AlgorithmDialog::setValue() to cope with this widget.");
}