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


C++ QDateTimeEdit::dateTime方法代码示例

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


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

示例1: on_btSetTime_clicked

void PosService::on_btSetTime_clicked()
{
    int button_width  = data->getVariables()->value(_S("standart_button_width")).toInt();
    int button_height = data->getVariables()->value(_S("standart_button_height")).toInt();
    int button_margin = data->getVariables()->value(_S("standart_margins")).toInt();

    QDialog dlg;

    QVBoxLayout* mainLayout = new QVBoxLayout();
    dlg.setLayout(mainLayout);

    dlg.setWindowTitle(_T("Установка времени"));

    QDateTimeEdit* edit = new QDateTimeEdit(QDateTime::currentDateTime());
    edit->setMaximumHeight(button_height);
    edit->setMinimumHeight(button_height);
    mainLayout->addWidget(edit);

    QHBoxLayout *btLayout = new QHBoxLayout();
    mainLayout->addLayout(btLayout);

    QPushButton* bt;

    bt = new QPushButton(_T("OK"), this);
    bt->setMaximumSize(button_width * 2 + button_margin, button_height);
    bt->setMinimumSize(button_width * 2 + button_margin, button_height);
    btLayout->addWidget(bt);
    connect(bt, SIGNAL(clicked()), &dlg, SLOT(accept()));

    bt = new QPushButton(_T("Отмена"), this);
    bt->setMaximumSize(button_width * 2 + button_margin, button_height);
    bt->setMinimumSize(button_width * 2 + button_margin, button_height);
    btLayout->addWidget(bt);
    connect(bt, SIGNAL(clicked()), &dlg, SLOT(reject()));

    int result = dlg.exec();
    if(result==QDialog::Accepted)
    {
        QString dt = edit->dateTime().toString(data->getSettings()->value("posservice/command_setdatetime_format").toString());
        QString command = data->getSettings()->value("posservice/command_setdatetime").toString().arg(dt);
        if (loglevel > 0)
            qDebug() << _T("%1 Устанавливаем новое время: %2 (было: %3)")
                        .arg(posForLog)
                        .arg(edit->dateTime().toString(Qt::ISODate))
                        .arg(QDateTime::currentDateTime().toString(Qt::ISODate));

        int result = QProcess::execute(command);
        if(result<0)
        {
            qDebug() << _T("%1 Ошибка установки нового времени. Код ошибки: %2")
                        .arg(posForLog)
                        .arg(result);

            QMessageBox message;
            message.setText(_T("Ошибка установки нового времени.\nКод ошибки: %1").arg(result));
            message.exec();
        }
    }
}
开发者ID:dmitry-aka-jok,项目名称:jpos2,代码行数:59,代码来源:posservice.cpp

示例2: setModelData

void QFRDRTableDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
    QFDoubleEdit *dEditor = qobject_cast<QFDoubleEdit *>(editor);
    if (dEditor) {
        QVariant v( dEditor->value());
        v.convert(QVariant::Double);
        //qDebug()<<v;
        model->setData(index, v);
    } else {
         QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
         if (dateEditor) {
             model->setData(index, dateEditor->dateTime());
         } else {
            QSpinBox *sEditor = qobject_cast<QSpinBox *>(editor);
             if (sEditor) {
                 model->setData(index, sEditor->value());
             } else {
                 QCheckBox *check = qobject_cast<QCheckBox *>(editor);
                 if (check) {
                      model->setData(index, check->isChecked());
                 } else {
                     QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
                     if (edit) {
                         model->setData(index, edit->text());
                    }
                 }
             }
         }
    }
}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:30,代码来源:qfrdrtabledelegate.cpp

示例3: readAnniversary

void ContactDialog::readAnniversary(int num, DateItem &ann)
{
    QDateTimeEdit* editor = findChild<QDateTimeEdit*>
        (QString("dteAnn%1Date").arg(num));
    if (!editor) return;
    anniversaryDetails[num-1].value = editor->dateTime();
    ann = anniversaryDetails[num-1];
}
开发者ID:DarkHobbit,项目名称:doublecontact,代码行数:8,代码来源:contactdialog.cpp

示例4: 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()
开发者ID:bewest,项目名称:diabetes-understanding-by-simulation,代码行数:27,代码来源:nlsimpleguiwindow.cpp

示例5: setModelData

void MyDateItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                      const QModelIndex &index) const
{
    QDateTimeEdit *e = static_cast<QDateTimeEdit*>(editor);
    e->interpretText();
    const QDateTime& value = e->dateTime();

    model->setData(index, value.toString(DATETIMEFORMAT), Qt::EditRole);
}
开发者ID:zanettea,项目名称:SAK,代码行数:9,代码来源:sakhits.cpp

示例6: setModelData

	void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
		if (!index.isValid())
			return;

		QDateTimeEdit *edit = qobject_cast<QDateTimeEdit *>(editor);
		if (!edit) {
			QItemDelegate::setModelData(editor, model, index);
			return;
		}

		model->setData(index, edit->dateTime().toString("yyyy-MM-dd hh:mm"), Qt::EditRole);
	}
开发者ID:hanzz,项目名称:hamlog,代码行数:12,代码来源:logbooktreewidget.cpp

示例7: setModelData

void MultiDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    QVariant value;

    QString  className = editor->metaObject()->className();
    if (className == "QTimeEdit") {
        QTimeEdit*  ed = qobject_cast<QTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->time());
    }
    else if (className == "QDateEdit") {
        QDateEdit*  ed = qobject_cast<QDateEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->date());
    }
    else if (className == "QDateTimeEdit") {
        QDateTimeEdit*  ed = qobject_cast<QDateTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->dateTime());
    }
    else if (className == "IconViewer") {
        return;
    }
    else if (className == "QComboBox") {
        QComboBox*  ed = qobject_cast<QComboBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->currentText());
    }
    else if (className == "QListWidget") {
        QListWidget*  ed = qobject_cast<QListWidget*>(editor);
        Q_ASSERT( ed);
        QStringList  valList;
        int  itemCount = ed->count();
        for (int i = 0; i < itemCount; ++i) {
            QListWidgetItem*  bitItem = ed->item(i);
            bool  isChecked = (bitItem->checkState() == Qt::Checked);
            if (isChecked)
                valList += bitItem->text();
        }
        value = QVariant( valList);
    }
    else if (className == "QCheckBox") {
        QCheckBox*  ed = qobject_cast<QCheckBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->isChecked());
    }
    else {
        QItemDelegate::setModelData( editor, model, index);
        return;
    }
    model->setData(index, value, Qt::EditRole);
}
开发者ID:micwik,项目名称:ArnBrowser,代码行数:53,代码来源:MultiDelegate.cpp

示例8: setModelData

void DateTimeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    QDateEdit *dateEdit = qobject_cast<QDateEdit*>(editor);
    if (dateEdit) {
        model->setData(index, dateEdit->date(), Qt::EditRole);
    } else {
        QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
        if (dateTimeEdit) {
            model->setData(index, dateTimeEdit->dateTime(), Qt::EditRole);
        }
    }
}
开发者ID:eads77m,项目名称:freemedforms,代码行数:13,代码来源:datetimedelegate.cpp

示例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 );
    }
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:15,代码来源:dlgbulkregister.cpp

示例10: DefaultGetter


//.........这里部分代码省略.........
		case SettingsPropertyMapper::RADIOBUTTON:
		{
			QRadioButton* pRadioButton = qobject_cast<QRadioButton*>(editor);
			if (pRadioButton == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pRadioButton->isChecked());
		}
		case SettingsPropertyMapper::CHECKABLE_GROUPBOX:
		{
			QGroupBox* pGroupBox = qobject_cast<QGroupBox*>(editor);
			if (pGroupBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			if (!pGroupBox->isCheckable())
			{
				qCritical() << "Given QGroupBox is not checkable";
			}
			return QVariant::fromValue(pGroupBox->isChecked());
		}
		case SettingsPropertyMapper::LINE_EDIT:
		{
			QLineEdit* pLineEdit = qobject_cast<QLineEdit*>(editor);
			if (pLineEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pLineEdit->text());
		}
		case SettingsPropertyMapper::TEXT_EDIT:
		{
			QTextEdit* pTextEdit = qobject_cast<QTextEdit*>(editor);
			if (pTextEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pTextEdit->toPlainText());
		}
		case SettingsPropertyMapper::COMBOBOX:
		{
			QComboBox* pComboBox = qobject_cast<QComboBox*>(editor);
			if (pComboBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pComboBox->currentIndex());
		}
		case SettingsPropertyMapper::SPINBOX:
		{
			QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor);
			if (pSpinBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pSpinBox->value());
		}
		case SettingsPropertyMapper::DOUBLE_SPINBOX:
		{
			QDoubleSpinBox* pDoubleSpinBox = qobject_cast<QDoubleSpinBox*>(editor);
			if (pDoubleSpinBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pDoubleSpinBox->value());
		}
		case SettingsPropertyMapper::TIME_EDIT:
		{
			QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor);
			if (pTimeEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pTimeEdit->time());
		}
		case SettingsPropertyMapper::DATETIME_EDIT:
		{
			QDateTimeEdit* pDateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
			if (pDateTimeEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return QVariant();
			}
			return QVariant::fromValue(pDateTimeEdit->dateTime());
		}
		default:
		{
			return QVariant();
		}
	}
}
开发者ID:sunpeng196,项目名称:CuteTorrent,代码行数:101,代码来源:UIPropertyGetters.cpp

示例11: QDialog

HistoryWidget::HistoryWidget(QWidget *parent)
    : QDialog(parent)
{
    setObjectName("HistoryWidget");
    setWindowTitle(tr("History Data View"));

    // layout - top
    QHBoxLayout *horiLayoutTop = new QHBoxLayout();

    QPushButton *buttonQuit = new QPushButton(this);
    buttonQuit->setObjectName("buttonQuit");
    horiLayoutTop->addSpacing(25);
    horiLayoutTop->addWidget(buttonQuit, 0, Qt::AlignLeft);
    horiLayoutTop->addStretch();

    // button-export
    QPushButton *buttonExport = new QPushButton(this);
    buttonExport->setObjectName("buttonExport");
    horiLayoutTop->addWidget(buttonExport);
    horiLayoutTop->addStretch();

    // button-open
    QPushButton *buttonOpen = new QPushButton(this);
    buttonOpen->setObjectName("buttonOpen");
    horiLayoutTop->addWidget(buttonOpen);
    horiLayoutTop->addStretch();

    QFormLayout *formLayoutTime = new QFormLayout();
    formLayoutTime->setFormAlignment(Qt::AlignVCenter);
    horiLayoutTop->addLayout(formLayoutTime);
    horiLayoutTop->addStretch();

    QDateTimeEdit *dateTimeEditStart = new QDateTimeEdit(this);
    dateTimeEditStart->setObjectName("dateTimeEditStart");
    dateTimeEditStart->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
    formLayoutTime->addRow(tr("Start Time:"), dateTimeEditStart);

    QDateTimeEdit *dateTimeEditEnd = new QDateTimeEdit(this);
    dateTimeEditEnd->setObjectName("dateTimeEditEnd");
    dateTimeEditEnd->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
    formLayoutTime->addRow(tr("End Time:"), dateTimeEditEnd);

    //LBP
    QFormLayout *formLayoutLBP = new QFormLayout();
    formLayoutLBP->setFormAlignment(Qt::AlignVCenter);
    formLayoutLBP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutLBP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxLBPMajor = new QCheckBox(tr("Major"), this);
    checkBoxLBPMajor->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxLBPMinor = new QCheckBox(tr("Minor"), this);
    checkBoxLBPMinor->setProperty("curveColor", "#101010");
    formLayoutLBP->addRow(tr("LBP:"), checkBoxLBPMajor);
    formLayoutLBP->addRow("", checkBoxLBPMinor);

    //RBP
    QFormLayout *formLayoutRBP = new QFormLayout();
    formLayoutRBP->setFormAlignment(Qt::AlignVCenter);
    formLayoutRBP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutRBP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxRBPMajor = new QCheckBox(tr("Major"), this);
    checkBoxRBPMajor->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxRBPMinor = new QCheckBox(tr("Minor"), this);
    checkBoxRBPMinor->setProperty("curveColor", "#101010");
    formLayoutRBP->addRow(tr("RBP:"), checkBoxRBPMajor);
    formLayoutRBP->addRow("", checkBoxRBPMinor);

    //LRP
    QFormLayout *formLayoutLRP = new QFormLayout();
    formLayoutLRP->setFormAlignment(Qt::AlignVCenter);
    formLayoutLRP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutLRP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxLRPTheory = new QCheckBox(tr("Theory"), this);
    checkBoxLRPTheory->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxLRPReal = new QCheckBox(tr("Real"), this);
    checkBoxLRPReal->setProperty("curveColor", "#101010");
    formLayoutLRP->addRow(tr("LRP:"), checkBoxLRPTheory);
    formLayoutLRP->addRow("", checkBoxLRPReal);

    //RRP
    QFormLayout *formLayoutRRP = new QFormLayout();
    formLayoutRRP->setFormAlignment(Qt::AlignVCenter);
    formLayoutRRP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutRRP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxRRPTheory = new QCheckBox(tr("Theory"), this);
    checkBoxRRPTheory->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxRRPReal = new QCheckBox(tr("Real"), this);
    checkBoxRRPReal->setProperty("curveColor", "#101010");
    formLayoutRRP->addRow(tr("RRP:"), checkBoxRRPTheory);
    formLayoutRRP->addRow("", checkBoxRRPReal);

    // button-update
    QPushButton *buttonUpdate = new QPushButton(this);
    buttonUpdate->setObjectName("buttonUpdate");
    horiLayoutTop->addWidget(buttonUpdate);
    horiLayoutTop->addStretch();
/*
//.........这里部分代码省略.........
开发者ID:iclosure,项目名称:carmonitor,代码行数:101,代码来源:history_widget.cpp

示例12: SaveMonthData

void CDlgBulkRegister::SaveMonthData( QStringList &lstDuplication, QStringList& lstTotalSql )
{
    int nRows = ui->tabRecord->rowCount( );
    QStringList lstSql;
    QString strTrue = "1";
    QString strFalse = "0";
    QString strDateTime = "";
    QDateTime dt;
    QString strQuotation = "'";
    bool bChecked = false;
    QComboBox* pCB = NULL;
    QDateTimeEdit* pDT = NULL;
    QString strText = "";
    QStringList lstExist;
    QStringList lstCardNo;

    for ( int nRow = 0; nRow < nRows; nRow++ ) {
        lstSql.clear( );
        strText = ui->tabRecord->item( nRow, 0 )->text( );

        CLogicInterface::GetInterface( )->ExistCardNumber(strText, lstExist );
        if ( 0 < lstExist.count( ) ) {
            lstDuplication << lstExist;
            continue;
        }

        QList< QTableWidgetItem* > lstItems = tabWidget->findItems( strText, Qt::MatchFixedString );
        if ( 0 < lstItems.count( ) ) {
            lstDuplication << strText;
            continue;
        }

        tabWidget->insertRow( 0 );
        lstCardNo << "'" + strText + "'";

        for ( int nCol = 0; nCol < ui->tabRecord->columnCount( ); nCol++ ) {
            switch ( nCol ) {
                case 0 :
                case 8 :
                case 9 :
                case 10 :
                    strText = ui->tabRecord->item( nRow, nCol )->text( );
                    lstSql  << ( strQuotation + strText + strQuotation );
                    AddItem( strText, 0, nCol, tabWidget );
                    break;

                case 1 :
                case 2 :
                case 3 :
                    bChecked = Qt::Checked == ui->tabRecord->item( nRow, nCol )->checkState( );
                    lstSql << ( bChecked ? strTrue : strFalse );
                    AddCheckBoxItem( 0, nCol, tabWidget, bChecked );
                    break;

                case 4 :
                case 7 :
                    pCB = ( QComboBox* ) ui->tabRecord->cellWidget( nRow, nCol );
                    strText = pCB->currentText( );
                    lstSql << ( strQuotation + strText + strQuotation );
                    AddItem( strText, 0, nCol, tabWidget );
                    break;

                case 5 :
                case 6 :
                    pDT = ( QDateTimeEdit* )  ui->tabRecord->cellWidget( nRow, nCol );
                    dt = pDT->dateTime( );
                    CCommonFunction::DateTime2String( dt, strDateTime );
                    lstSql << ( strQuotation + strDateTime + strQuotation );
                    AddItem( strDateTime, 0, nCol, tabWidget );
                    break;
            }
        }

        lstTotalSql << ( "(" + lstSql.join( "," ) + " )" );
    }

    emit BroadcastCardNo( lstCardNo );
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:78,代码来源:dlgbulkregister.cpp

示例13: setModelData

void DateTimeCalendarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                const QModelIndex &index) const
{
    QDateTimeEdit *e = static_cast<QDateTimeEdit*>(editor);
    model->setData( index, e->dateTime(), Qt::EditRole );
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:6,代码来源:kptitemmodelbase.cpp


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