本文整理汇总了C++中QDateEdit类的典型用法代码示例。如果您正苦于以下问题:C++ QDateEdit类的具体用法?C++ QDateEdit怎么用?C++ QDateEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDateEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCheckBox
QWidget *MySqlRelationDelegate::createEditor(QWidget *aParent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0;
if (!childModel)
{
if (HandbookDialog::m_record.fieldName(index.column()).contains("IS_", Qt::CaseSensitive))
{
QCheckBox * checkBox = new QCheckBox(aParent);
checkBox->setChecked(index.data().toInt() > 0);
return checkBox;
}
else if (HandbookDialog::m_record.fieldName(index.column()).contains("DATE_", Qt::CaseSensitive))
{
QDateEdit * dateEdit = new QDateEdit(aParent);
dateEdit->setDate(QDate::fromString(index.data().toString(), "yyyy-MM-dd"));
return dateEdit;
}
else
{
return QItemDelegate::createEditor(aParent, option, index);
}
}
QComboBox *combo = new QComboBox(aParent);
combo->setModel(childModel);
combo->setModelColumn(childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn()));
combo->installEventFilter(const_cast<MySqlRelationDelegate *>(this));
return combo;
}
示例2: if
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void UKvyt_Delegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
if (index.column() == durationColumn_2) {
double value = index.model()->data(index, Qt::DisplayRole).toDouble();
QDoubleSpinBox *double_spinbox = qobject_cast<QDoubleSpinBox *>(editor);
double_spinbox->setValue(value);
double_spinbox->selectAll();
}
else if ( (index.column() == durationColumn_3) || (index.column() == durationColumn_4) ){
QDateEdit * dateEdit = qobject_cast<QDateEdit *>(editor);
dateEdit->setDate( index.model()->data(index, Qt::DisplayRole).toDate() );
dateEdit->setCurrentSection( QDateTimeEdit::DaySection );
dateEdit->stepBy( 0 );
}
else if ((index.column() == durationColumn_5) || (index.column() == durationColumn_1)){
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QSpinBox *spinbox = qobject_cast<QSpinBox *>(editor);
spinbox->setValue(value);
spinbox->selectAll();
}
else {
QSqlRelationalDelegate::setEditorData(editor, index);
}
}
示例3: switch
QWidget *PupilSingularActivityDelegate::createEditor ( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
switch ( index.column() ) {
case 2: {
QDateEdit *cal = new QDateEdit ( parent );
cal->setCalendarPopup ( true );
connect ( cal, SIGNAL ( dateChanged ( const QDate ) ), this, SLOT ( emitCommitData() ) );
return cal;
}
break;
case 3: {
QComboBox *combo = new QComboBox ( parent );
QStringList myTypeList;
myTypeList << "Solo-Vortrag" << "Ensemble-Mitwirkung" << "sonstiges";
combo->insertItems ( 0, myTypeList );
connect ( combo, SIGNAL ( activated ( int ) ), this, SLOT ( emitCommitData() ) );
return combo;
}
break;
default:
return QItemDelegate::createEditor ( parent, option, index );
break;
}
}
示例4: QCalendarWidget
QDate QtopiaInputDialog::getDate(QWidget *parent, const QString &title, const QString &label, const QDate &date,
const QDate &minDate, const QDate &maxDate, bool *ok)
{
#ifdef CALENDAR_FOR_DATE
QCalendarWidget *cal = new QCalendarWidget();
cal->setSelectedDate(date);
cal->setMinimumDate(minDate);
cal->setMaximumDate(maxDate);
cal->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
QTextCharFormat headerFormat = cal->headerTextFormat();
headerFormat.setBackground(QApplication::palette().window());
headerFormat.setForeground(QApplication::palette().windowText());
cal->setHeaderTextFormat(headerFormat);
QWidget *navBar = cal->findChild<QWidget*>("qt_calendar_navigationbar");
if (navBar)
navBar->setBackgroundRole(QPalette::Window);
QtopiaInputDialog dlg(parent, title, label, cal);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
return cal->selectedDate();
#else
QDateEdit *de = new QDateEdit(date);
de->setMinimumDate(minDate);
de->setMaximumDate(maxDate);
QtopiaInputDialog dlg(parent, title, label, de);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
return de->date();
#endif
}
示例5: switch
QWidget *DBFRedactorDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
const DBFRedactor::Field& field = m_redactor->field(index.column());
switch (field.type) {
case DBFRedactor::TYPE_DATE: {
QDateEdit *edit = new QDateEdit(parent);
edit->setCalendarPopup(true);
return edit;
break;
}
case DBFRedactor::TYPE_FLOAT: case DBFRedactor::TYPE_NUMERIC: {
QDoubleSpinBox *edit = new QDoubleSpinBox(parent);
edit->setDecimals(field.secondLenght);
QString tempString;
tempString.fill('9', field.firstLenght - 1);
edit->setMinimum(tempString.toDouble() * (-1));
tempString.fill('9', field.firstLenght);
edit->setMaximum(tempString.toDouble());
return edit;
break;
}
default: {
QLineEdit *edit = new QLineEdit(parent);
edit->setMaxLength(field.firstLenght);
return edit;
}
}
return 0;
}
示例6: setEditorData
void DateDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QDateEdit * dateEdit = static_cast<QDateEdit*>(editor);
QDate date;
date = index.model()->data(index,Qt::DisplayRole).toDate();
dateEdit->setDate(date);
}
示例7: switch
//------------------------------------------------------------------------------
void ConditionValueDelegate::setModelData(QWidget* editor,
QAbstractItemModel* model, const QModelIndex& index) const
{
switch (field(index))
{
case AssignmentRule::Date:
{
QDateEdit* dateEditor = static_cast<QDateEdit*>(editor);
QDate date = dateEditor->date();
model->setData(index, date.toString(Qt::ISODate), Qt::EditRole);
}
break;
case AssignmentRule::Amount:
{
MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor);
Money amount = moneyEditor->value();
QString newVal = QString("%1,%2")
.arg(amount.amount()).arg(amount.currency().code());
model->setData(index, newVal, Qt::EditRole);
}
break;
default:
{
LineEdit* stringEditor = static_cast<LineEdit*>(editor);
model->setData(index, stringEditor->text(), Qt::EditRole);
}
}
}
示例8: sender
void TransactionWidget::dateChanged( const QDate &date )
{
if( !sender() )
return;
QDateEdit *edit = qobject_cast<QDateEdit *>( sender() );
if( !edit )
return;
QString name = edit->objectName();
QDate date1 = startDateEdit->date();
QDate date2 = endDateEdit->date();
if( date1 >= date2 )
{
if( name == "endDateEdit" )
{
date1 = date1.addDays(-1);
startDateEdit->setDate( date1 );
}
else if( name == "startDateEdit" )
{
date2 = date2.addDays(1);
endDateEdit->setDate( date2 );
}
}
}
示例9: Q_UNUSED
QWidget* Date::createEditor(QWidget * parent, const QModelIndex & index)
{
Q_UNUSED(index);
QDateEdit *de = new QDateEdit(parent);
de->setDate(value().toDate());
connect(de, SIGNAL(dateChanged(const QDate&)), this, SLOT(setValue(const QDate&)));
return de;
}
示例10: setModelData
void DateDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QDateEdit * dateEdit = static_cast<QDateEdit*>(editor);
QString value = dateEdit->date().toString("yyyy-MM-dd");
model->setData(index, value, Qt::EditRole);
}
示例11: QDateEdit
QWidget *CalendarDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem& /* option */,
const QModelIndex& /* index */) const {
QDateEdit *editor = new QDateEdit(parent);
editor->setCalendarPopup(m_calpopup);
editor->installEventFilter(const_cast<CalendarDelegate*>(this));
connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
return editor;
}
示例12: Q_UNUSED
QWidget *DateDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
QDateEdit * dateEdit = new QDateEdit(parent);
dateEdit->setDisplayFormat("yyyy-MM-dd");
return dateEdit;
}
示例13: switch
uint64_t ExprParamElement::getIntValueFromField(QString fieldName, bool isToField,bool *ok)
{
uint64_t val = 0;
if(ok!=NULL)
*ok=true ;
QString suffix = (isToField) ? "2": "1" ;
// NOTE qFindChild necessary for MSVC 6 compatibility!!
switch (searchType)
{
case DateSearch:
{
QDateEdit * dateEdit = qFindChild<QDateEdit *> (internalframe, (fieldName + suffix));
QDateTime * time = new QDateTime(dateEdit->date());
val = (uint64_t)time->toTime_t();
break;
}
case SizeSearch:
{
QLineEdit * lineEditSize = qFindChild<QLineEdit*>(internalframe, (fieldName + suffix));
bool ok2 = false;
val = (lineEditSize->displayText()).toULongLong(&ok2);
if (ok2)
{
QComboBox * cb = qFindChild<QComboBox*> (internalframe, (QString("unitsCb") + suffix));
QVariant data = cb->itemData(cb->currentIndex());
val *= data.toULongLong();
}
else
if(ok!=NULL)
*ok=false ;
break;
}
case PopSearch: // not implemented
/* {
QLineEdit * lineEditPop = qFindChild<QLineEdit*>(elem, (fieldName + suffix));
bool ok = false;
val = (lineEditPop->displayText()).toInt(&ok);
if (!ok) {
val = -1;
}
break;
}*/
case NameSearch:
case PathSearch:
case ExtSearch:
case HashSearch:
default:
// shouldn't be here...val stays at -1
if(ok!=NULL)
*ok=false ;
}
return val;
}
示例14: QGroupBox
//! [6]
void Window::createDateTimeEdits()
{
editsGroup = new QGroupBox(tr("Date and time spin boxes"));
QLabel *dateLabel = new QLabel;
QDateEdit *dateEdit = new QDateEdit(QDate::currentDate());
dateEdit->setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31));
dateLabel->setText(tr("Appointment date (between %0 and %1):")
.arg(dateEdit->minimumDate().toString(Qt::ISODate))
.arg(dateEdit->maximumDate().toString(Qt::ISODate)));
//! [6]
//! [7]
QLabel *timeLabel = new QLabel;
QTimeEdit *timeEdit = new QTimeEdit(QTime::currentTime());
timeEdit->setTimeRange(QTime(9, 0, 0, 0), QTime(16, 30, 0, 0));
timeLabel->setText(tr("Appointment time (between %0 and %1):")
.arg(timeEdit->minimumTime().toString(Qt::ISODate))
.arg(timeEdit->maximumTime().toString(Qt::ISODate)));
//! [7]
//! [8]
meetingLabel = new QLabel;
meetingEdit = new QDateTimeEdit(QDateTime::currentDateTime());
//! [8]
//! [9]
QLabel *formatLabel = new QLabel(tr("Format string for the meeting date "
"and time:"));
QComboBox *formatComboBox = new QComboBox;
formatComboBox->addItem("yyyy-MM-dd hh:mm:ss (zzz 'ms')");
formatComboBox->addItem("hh:mm:ss MM/dd/yyyy");
formatComboBox->addItem("hh:mm:ss dd/MM/yyyy");
formatComboBox->addItem("hh:mm:ss");
formatComboBox->addItem("hh:mm ap");
//! [9] //! [10]
connect(formatComboBox, SIGNAL(activated(const QString &)),
this, SLOT(setFormatString(const QString &)));
//! [10]
setFormatString(formatComboBox->currentText());
//! [11]
QVBoxLayout *editsLayout = new QVBoxLayout;
editsLayout->addWidget(dateLabel);
editsLayout->addWidget(dateEdit);
editsLayout->addWidget(timeLabel);
editsLayout->addWidget(timeEdit);
editsLayout->addWidget(meetingLabel);
editsLayout->addWidget(meetingEdit);
editsLayout->addWidget(formatLabel);
editsLayout->addWidget(formatComboBox);
editsGroup->setLayout(editsLayout);
}
示例15: setEditorData
void BudgetEntityDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
BudgetEntity entity = qvariant_cast<BudgetEntity>(index.data());
QDateEdit *dateEdit = qobject_cast<QDateEdit *>( editor->layout()->itemAt(0)->widget() );
QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>( editor->layout()->itemAt(1)->widget() );
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox *>( editor->layout()->itemAt(2)->widget() );
dateEdit->setDate(entity.date());
textEdit->setPlainText(entity.description());
spinBox->setValue(entity.amount());
}