本文整理汇总了C++中QDateTimeEdit::setDateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTimeEdit::setDateTime方法的具体用法?C++ QDateTimeEdit::setDateTime怎么用?C++ QDateTimeEdit::setDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTimeEdit
的用法示例。
在下文中一共展示了QDateTimeEdit::setDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDisplayTimeLimitsConsistency
//Check to make sure display time comes before end display time
void NLSimpleGuiWindow::checkDisplayTimeLimitsConsistency()
{
QDateTimeEdit *endEntry = ui->endDisplayTime;
QDateTimeEdit *startEntry = ui->startDisplayTime;
if( startEntry->dateTime() <= endEntry->dateTime() )
return;
if( posixTimeToQTime(kGenericT0) == endEntry->dateTime() )
return;
if( posixTimeToQTime(kGenericT0) == startEntry->dateTime() )
return;
QObject *caller = QObject::sender();
if( caller == dynamic_cast<QObject *>(endEntry) )
{
endEntry->setDateTime( startEntry->dateTime() );
}else if( caller == dynamic_cast<QObject *>(startEntry) )
{
startEntry->setDateTime( endEntry->dateTime() );
}else
{
cout << "void NLSimpleGuiWindow::checkDisplayTimeLimitsConsistency()"
<< " error in caller logic" << endl;
endEntry->setDateTime( startEntry->dateTime() );
}//
}//void NLSimpleGuiWindow::checkDisplayTimeLimitsConsistency()
示例2: setEditorData
void DateTimeCalendarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QDateTime value = index.model()->data(index, Qt::EditRole).toDateTime();
QDateTimeEdit *e = static_cast<QDateTimeEdit*>(editor);
e->setDateTime( value );
}
示例3: setEditorData
void QFRDRTableDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
if (dateEditor) {
dateEditor->setDateTime(index.model()->data(index, Qt::EditRole).toDateTime());
} else {
QFDoubleEdit *dEditor = qobject_cast<QFDoubleEdit *>(editor);
if (dEditor) {
dEditor->setValue(index.model()->data(index, Qt::EditRole).toDouble());
} else {
QSpinBox *sEditor = qobject_cast<QSpinBox *>(editor);
if (sEditor) {
sEditor->setValue(index.model()->data(index, Qt::EditRole).toLongLong());
} else {
QCheckBox *check = qobject_cast<QCheckBox *>(editor);
if (check) {
check->setChecked(index.model()->data(index, Qt::EditRole).toBool());
} else {
QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
if (edit) {
edit->setText(index.model()->data(index, Qt::EditRole).toString());
}
}
}
}
}
}
示例4: setEditorData
void MyDateItemDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
const QDateTime& value = index.model()->data(index, Qt::DisplayRole).toDateTime();
QDateTimeEdit *e = static_cast<QDateTimeEdit*>(editor);
e->setDateTime(value);
}
示例5: setEditorData
void setEditorData(QWidget *editor, const QModelIndex &index) const {
QDateTimeEdit *edit = qobject_cast<QDateTimeEdit *>(editor);
if (!edit) {
QItemDelegate::setEditorData(editor, index);
return;
}
QString time = index.model()->data(index,Qt::EditRole).toString();
edit->setDateTime(QDateTime::fromString(time, "yyyy-MM-dd hh:mm"));
}
示例6: QDateTimeEdit
QWidget *MyDateItemDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex & index ) const
{
QDateTimeEdit *editor = new QDateTimeEdit(parent);
editor->setCalendarPopup(true);
editor->setDisplayFormat(DATETIMEFORMAT);
editor->setDateTime(QDateTime::fromString(index.data().toString(), DATETIMEFORMAT));
return editor;
}
示例7: setEditorData
void DateTimeDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QDateEdit *dateEdit = qobject_cast<QDateEdit*>(editor);
if (dateEdit) {
dateEdit->setDate(index.data(Qt::EditRole).toDate());
} else {
QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
if (dateTimeEdit) {
dateTimeEdit->setDateTime(index.data(Qt::EditRole).toDateTime());
}
}
}
示例8: QWidget
QWidget*
Dynamic::WeeklyTopBias::widget( QWidget* parent )
{
QWidget *widget = new QWidget( parent );
QVBoxLayout *layout = new QVBoxLayout( widget );
QLabel *label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "from:" ) );
QDateTimeEdit *fromEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) );
fromEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm
fromEdit->setMaximumDate( QDate::currentDate() );
fromEdit->setCalendarPopup( true );
if( m_range.from.isValid() )
fromEdit->setDateTime( m_range.from );
connect( fromEdit, SIGNAL( dateTimeChanged( const QDateTime& ) ),
this, SLOT( fromDateChanged( const QDateTime& ) ) );
label->setBuddy( fromEdit );
layout->addWidget( label );
layout->addWidget( fromEdit );
label = new QLabel( i18nc( "in WeeklyTopBias. Label for the date widget", "to:" ) );
QDateTimeEdit *toEdit = new QDateTimeEdit( QDate::currentDate().addDays( -7 ) );
toEdit->setMinimumDate( QDateTime::fromTime_t( 1111320001 ).date() ); // That's the first week in last fm
toEdit->setMaximumDate( QDate::currentDate() );
toEdit->setCalendarPopup( true );
if( m_range.to.isValid() )
toEdit->setDateTime( m_range.to );
connect( toEdit, SIGNAL( dateTimeChanged( const QDateTime& ) ),
this, SLOT( toDateChanged( const QDateTime& ) ) );
label->setBuddy( toEdit );
layout->addWidget( label );
layout->addWidget( toEdit );
return widget;
}
示例9: OnBulkMonth
void CDlgBulkRegister::OnBulkMonth( int nMonth )
{
QDateTimeEdit* pDt = NULL;
QDateTime dtStart;
for ( int nRow = 0; nRow < ui->tabRecord->rowCount( ); nRow++ ) {
pDt = ( QDateTimeEdit* ) ui->tabRecord->cellWidget( nRow, 5 );
dtStart = pDt->dateTime( );
pDt = ( QDateTimeEdit* ) ui->tabRecord->cellWidget( nRow, 6 );
dtStart = dtStart.addMonths( nMonth );
//qDebug( ) << dtStart.toString( ) << endl;
pDt->setDateTime( dtStart );
}
}
示例10: addAnniversary
void ContactDialog::addAnniversary(const DateItem &ann)
{
anniversaryDetails.push_back(ann);
// Value
QDateTimeEdit* dte = new QDateTimeEdit(this);
dte->setObjectName(QString("dteAnn%1Date").arg(anniversaryCount+1));
dte->setDateTime(ann.value);
DateDetailsDialog::setDateFormat(dte, ann.hasTime);
dte->setCalendarPopup(true);
layAnniversaries->addWidget(dte, anniversaryCount, 0);
// Details button
QPushButton* btnDet = new QPushButton(this);
btnDet->setObjectName(QString("btnAnn%1Details").arg(anniversaryCount+1));
btnDet->setText(ui->btnBDayDetails->text());
connect(btnDet, SIGNAL(clicked()), this, SLOT(slotAnnDetails()));
layAnniversaries->addWidget(btnDet, anniversaryCount, 1);
// Delete button
QToolButton* btnD = addDelButton(anniversaryCount, "Ann", SLOT(slotDelAnniversary()));
layAnniversaries->addWidget(btnD, anniversaryCount, 2);
anniversaryCount++;
}
示例11: QDateEdit
QWidget *DateTimeDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &index) const
{
// TODO: use the ModernDateEditor editor
if (m_IsDateOnly) {
QDateEdit *editor = new QDateEdit(parent);
editor->setMinimumDate(m_MinDate);
editor->setMaximumDate(m_MaxDate);
editor->setCalendarPopup(true);
editor->setDisplayFormat(tkTr(Trans::Constants::DATEFORMAT_FOR_EDITOR));
editor->setDate(index.data(Qt::EditRole).toDate());
return editor;
} else {
QDateTimeEdit *editor = new QDateTimeEdit(parent);
editor->setMinimumDateTime(QDateTime(m_MinDate, m_MinTime));
editor->setMaximumDateTime(QDateTime(m_MaxDate, m_MaxTime));
editor->setDisplayFormat(tkTr(Trans::Constants::DATETIMEFORMAT_FOR_EDITOR));
editor->setDateTime(index.data().toDateTime());
return editor;
}
return 0;
}
示例12: DefaultSetter
//.........这里部分代码省略.........
}
case SettingsPropertyMapper::TEXT_EDIT:
{
QTextEdit* pTextEdit = qobject_cast<QTextEdit*>(editor);
if (pTextEdit == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::STRING)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pTextEdit->setText(propertyValue.toString());
break;
}
case SettingsPropertyMapper::COMBOBOX:
{
QComboBox* pComboBox = qobject_cast<QComboBox*>(editor);
if (pComboBox == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::INT)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pComboBox->setCurrentIndex(propertyValue.toInt());
break;
}
case SettingsPropertyMapper::SPINBOX:
{
QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor);
if (pSpinBox == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::INT)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pSpinBox->setValue(propertyValue.toInt());
break;
}
case SettingsPropertyMapper::DOUBLE_SPINBOX:
{
QDoubleSpinBox* pDoubleSpinBox = qobject_cast<QDoubleSpinBox*>(editor);
if (pDoubleSpinBox == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::DOUBLE)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pDoubleSpinBox->setValue(propertyValue.toDouble());
break;
}
case SettingsPropertyMapper::TIME_EDIT:
{
QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor);
if (pTimeEdit == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::TIME)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pTimeEdit->setTime(propertyValue.toTime());
break;
}
case SettingsPropertyMapper::DATETIME_EDIT:
{
QDateTimeEdit* pDateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
if (pDateTimeEdit == NULL)
{
qCritical() << "Invalid editor given";
return;
}
if (propertyType != SettingsPropertyMapper::DATETIME)
{
qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
return;
}
pDateTimeEdit->setDateTime(propertyValue.toDateTime());
break;
}
default: break;
}
}
示例13: createEditor
QWidget* MultiDelegate::createEditor( QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
const QAbstractItemModel* model = index.model();
QVariant value = model->data( index, Qt::EditRole);
switch (value.type()) {
case QMetaType::QTime:
{
QTimeEdit* editor = new QTimeEdit( parent);
editor->setMaximumWidth( editor->sizeHint().width());
//// Get value snapshot into editor
editor->setTime( value.toTime());
return editor;
}
case QMetaType::QDate:
{
QDateEdit* editor = new QDateEdit( parent);
setupCalenderWidget( editor);
editor->setMaximumWidth( editor->sizeHint().width());
//// Get value snapshot into editor
editor->setDate( value.toDate());
return editor;
}
case QMetaType::QDateTime:
{
QDateTimeEdit* editor = new QDateTimeEdit( parent);
setupCalenderWidget( editor);
editor->setMaximumWidth( editor->sizeHint().width());
editor->setDateTime( value.toDateTime());
return editor;
}
case QMetaType::QImage:
// Fall throu
case QMetaType::QPixmap:
// Fall throu
case QMetaType::QIcon:
{
PixmapViewer* editor = new PixmapViewer( parent);
connect( editor, SIGNAL(finished(int)), this, SLOT(closeEmittingEditor()));
return editor;
}
case QMetaType::QStringList:
{
QVariant varList = index.model()->data( index, ItemDataRole::EnumList);
if (varList.isNull()) break; // Not a enum-list, fall to std
QListWidget* editor = new QListWidget( parent);
foreach (const QString& bitItemText, varList.toStringList()) {
QListWidgetItem* bitItem = new QListWidgetItem( bitItemText, editor);
bitItem->setFlags(bitItem->flags() | Qt::ItemIsUserCheckable);
bitItem->setCheckState(Qt::Unchecked);
}
int width = editor->sizeHintForColumn(0) + 25;
int height = editor->sizeHintForRow(0) * editor->count() + 10;
editor->setMinimumWidth( width);
editor->setMaximumWidth( width);
editor->setMinimumHeight( height);
editor->setMaximumHeight( height);
//// Get value snapshot into editor
QStringList valList = value.toStringList();
int itemCount = editor->count();
for (int i = 0; i < itemCount; ++i) {
QListWidgetItem* bitItem = editor->item(i);
bool isActive = valList.contains( bitItem->text());
bitItem->setCheckState( isActive ? Qt::Checked : Qt::Unchecked);
}
return editor;
}
case QMetaType::QString:
{
QVariant varList = index.model()->data( index, ItemDataRole::EnumList);
if (varList.isNull()) break; // Not a enum-list, fall to std
QComboBox* editor = new QComboBox( parent);
editor->setSizeAdjustPolicy(QComboBox::AdjustToContents);
editor->addItems( varList.toStringList());
editor->setMaximumWidth( editor->minimumSizeHint().width());
//// Get value snapshot into editor
editor->setCurrentIndex( editor->findText( value.toString()));
return editor;
}
default:;
}
if (index.column() == 0) {
emit itemEditTrigged( index);
return 0; // No inline editor
}
QWidget* editor = QItemDelegate::createEditor( parent, option, index);
//// Get value snapshot into editor
QItemDelegate::setEditorData( editor, index);
return editor;
//.........这里部分代码省略.........
示例14: fileDialog
//.........这里部分代码省略.........
connect(buttonOpen, &QPushButton::clicked, this, [=](){
QFileDialog fileDialog(this,
tr("Open history database files"),
QApplication::applicationDirPath().append("/../data"),
tr("Data Base File (*.db *.mdb)"));
if (fileDialog.exec() == QDialog::Rejected) {
return;
}
// clear curve
curveHistory->clear();
//
QStringList filePaths = fileDialog.selectedFiles();
if (filePaths.isEmpty()) {
return;
}
QString filePath = filePaths.first();
if (filePath.isEmpty()) {
return;
}
// open database
if (!DataBaseMgr::instance().open(filePath)) {
Q_ASSERT(false);
return;
}
//
QDateTime startTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().startTime());
QDateTime endTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().endTime());
dateTimeEditStart->setDateTimeRange(startTime, endTime);
dateTimeEditEnd->setDateTimeRange(startTime, endTime);
dateTimeEditEnd->setDateTime(endTime);
dateTimeEditStart->setDateTime(startTime);
// curve title
curveHistory->setTitle(tr("History Data View")
.append(" (")
.append(QFileInfo(filePath).fileName())
.append(")"));
});
connect(buttonExport, &QPushButton::clicked, this, [=](){
QStringList filePaths = QFileDialog::getOpenFileNames(this,
tr("Convert data base files to txt format and save..."),
QApplication::applicationDirPath().append("/../data"),
tr("Data Base File (*.db *.mdb)"));
if (filePaths.isEmpty()) {
return;
}
//
if (DataBaseMgr::instance().convertToText(filePaths)) {
QMessageBox::information(this, tr("Convert Database file"), tr("Convert successfully!"));
} else {
QMessageBox::information(this, tr("Convert Database file"), tr("Convert failed!"));
}
});
connect(dateTimeEditStart, &QDateTimeEdit::dateTimeChanged, this, [=](const QDateTime &dateTime){
QDateTime endDateTime = dateTimeEditEnd->dateTime();
if (dateTime > endDateTime) {
dateTimeEditStart->setDateTime(endDateTime);
}
示例15: propertyUpdated
void protoObject::propertyUpdated(QString propertyName){
QObject *receiver = mapper->mapping(propertyName);
QWidget *widget;
if (receiver) return; //if not binding, just leave
widget = qobject_cast<QLabel*>(receiver);
if (widget) {
QLabel* edit = qobject_cast<QLabel*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(edit->text().arg(value));
edit->blockSignals(false);
};
widget = qobject_cast<QLineEdit*>(receiver);
if (widget) {
QLineEdit* edit = qobject_cast<QLineEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QComboBox*>(receiver);
if (widget) {
QComboBox* edit = qobject_cast<QComboBox*>(receiver);
edit->blockSignals(true);
edit->setCurrentIndex(edit->findData(this->property(propertyName.toLatin1()), Qt::UserRole));
edit->blockSignals(false);
};
widget = qobject_cast<QRadioButton*>(receiver);
if (widget) {
QRadioButton* edit = qobject_cast<QRadioButton*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QCheckBox*>(receiver);
if (widget) {
QCheckBox* edit = qobject_cast<QCheckBox*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QPlainTextEdit*>(receiver);
if (widget) {
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setPlainText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QSpinBox*>(receiver);
if (widget) {
QSpinBox* edit = qobject_cast<QSpinBox*>(receiver);
int value = this->property(propertyName.toLatin1()).toInt();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDoubleSpinBox*>(receiver);
if (widget) {
QDoubleSpinBox* edit = qobject_cast<QDoubleSpinBox*>(receiver);
double value = this->property(propertyName.toLatin1()).toDouble();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDateTimeEdit*>(receiver);
if (widget) {
QDateTimeEdit* edit = qobject_cast<QDateTimeEdit*>(receiver);
QDateTime value = this->property(propertyName.toLatin1()).toDateTime();
edit->blockSignals(true);
edit->setDateTime(value);
edit->blockSignals(false);
};
}