本文整理汇总了C++中QTimeEdit::time方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeEdit::time方法的具体用法?C++ QTimeEdit::time怎么用?C++ QTimeEdit::time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimeEdit
的用法示例。
在下文中一共展示了QTimeEdit::time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareTime
void CTariffSetting::CompareTime( QTimeEdit &edtTime, QTime &time, bool bSequence )
{
if ( !edtTime.isVisible( ) ) {
return;
}
bool bDisplay = bSequence ? ( time > edtTime.time( ) ) : ( time < edtTime.time( ) );
QString strStyle = bDisplay ? "background-color: rgb(255, 0, 0);" :
"background-color: rgb(255, 255, 255);";
if ( bDisplay ) {
edtTime.setFocus( );
QString strInfo = QString( "%1时间不能%2于%3时间" ).arg( bSequence ? "截止" : "起始",
bSequence ? "小" : "大",
bSequence ? "起始" : "截止" );
CCommonFunction::MsgBox( NULL, CCommonFunction::GetMsgTitle( QMessageBox::Information ),
strInfo, QMessageBox::Information );
}
QString strWhite = "background-color: rgb(255, 255, 255);";
ui->tdtSection1->setStyleSheet( strWhite );
ui->tdtSection2->setStyleSheet( strWhite );
edtTime.setStyleSheet( strStyle );
}
示例2: setModelData
void TrackDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
if ( !index.isValid())
{
return;
}
QTimeEdit* timeEditor = qobject_cast<QTimeEdit*>(editor);
if ( !timeEditor)
{
return;
}
if (isRightColumn(index, TrackDelegate::columnNumber))
{
QTime time = timeEditor->time();
int secs = time.hour() * 60 + time.minute();
//int secs = index.model()->data(index, Qt::EditRole).toInt();
model->setData(index, secs, Qt::EditRole);
}
else
{
QStyledItemDelegate::setModelData(editor, model, index);
}
}
示例3: timesChanged
void MainWindow::timesChanged(QTime t) {
//when time edit event occur
return;
QWidget *wid = QApplication::focusWidget();
QTimeEdit *cell = qobject_cast<QTimeEdit*>(wid);
QTimeEdit *st;
QTimeEdit *et;
QSpinBox *du;
int start, end;
if (wid) {
QModelIndex index = widget.tableWidget->indexAt(cell->pos());
// cout << index.row() << " " << index.column() << endl;
if (index.column() == 0) {
st = cell;
et = qobject_cast<QTimeEdit*>(widget.tableWidget->cellWidget(index.row(), 1));
} else {
et = cell;
st = qobject_cast<QTimeEdit*>(widget.tableWidget->cellWidget(index.row(), 0));
}
QTime tt;
tt = st->time();
start = tt.msec() + 1000 * (tt.second() + tt.minute()*60 + tt.hour()*3600);
tt = et->time();
end = tt.msec() + 1000 * (tt.second() + tt.minute()*60 + tt.hour()*3600);
if (start > end) {
if (index.column() == 0) {
// st->setTime(et->time());
} else {
// et->setTime(st->time());
}
}
du = qobject_cast<QSpinBox*>(widget.tableWidget->cellWidget(index.row(), 2));
du->setValue(end - start);
delete wid;
delete cell;
delete et;
delete st;
delete du;
}
}
示例4: setModelData
void PupilContActivityDelegate::setModelData ( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
{
switch ( index.column() ) {
case 2: {
QComboBox *combo = qobject_cast<QComboBox *> ( editor );
if ( !combo ) {
QItemDelegate::setModelData ( editor, model, index );
return;
}
model -> setData ( index, combo -> currentIndex() );
}
break;
case 3: {
QComboBox *combo = qobject_cast<QComboBox *> ( editor );
if ( !combo ) {
QItemDelegate::setModelData ( editor, model, index );
return;
}
model -> setData ( index, combo -> currentIndex() );
}
break;
case 4: {
QTimeEdit *time = qobject_cast<QTimeEdit *> ( editor );
if ( !time ) {
QItemDelegate::setModelData ( editor, model, index );
}
model -> setData ( index, time->time().toString("hh:mm") );
}
break;
case 5: {
QDateEdit *cal = qobject_cast<QDateEdit *> ( editor );
if ( !cal ) {
QItemDelegate::setModelData ( editor, model, index );
return;
}
model -> setData ( index, cal->date().toString("yyyy-MM-dd") );
}
break;
case 6: {
QDateEdit *cal1 = qobject_cast<QDateEdit *> ( editor );
if ( !cal1 ) {
QItemDelegate::setModelData ( editor, model, index );
return;
}
model -> setData ( index, cal1->date().toString("yyyy-MM-dd") );
}
break;
default: {
QItemDelegate::setModelData ( editor, model, index );
return;
}
break;
}
}
示例5: dateTimeEditor
void tst_QItemDelegate::dateTimeEditor()
{
QFETCH(QTime, time);
QFETCH(QDate, date);
QTableWidgetItem *item1 = new QTableWidgetItem;
item1->setData(Qt::DisplayRole, time);
QTableWidgetItem *item2 = new QTableWidgetItem;
item2->setData(Qt::DisplayRole, date);
QTableWidgetItem *item3 = new QTableWidgetItem;
item3->setData(Qt::DisplayRole, QDateTime(date, time));
QTableWidget widget(1, 3);
widget.setItem(0, 0, item1);
widget.setItem(0, 1, item2);
widget.setItem(0, 2, item3);
widget.show();
widget.editItem(item1);
QTestEventLoop::instance().enterLoop(1);
QTimeEdit *timeEditor = qFindChild<QTimeEdit *>(widget.viewport());
QVERIFY(timeEditor);
QCOMPARE(timeEditor->time(), time);
widget.clearFocus();
qApp->setActiveWindow(&widget);
widget.setFocus();
widget.editItem(item2);
QTestEventLoop::instance().enterLoop(1);
QDateEdit *dateEditor = qFindChild<QDateEdit *>(widget.viewport());
QVERIFY(dateEditor);
QCOMPARE(dateEditor->date(), date);
widget.clearFocus();
widget.setFocus();
widget.editItem(item3);
QTestEventLoop::instance().enterLoop(1);
QList<QDateTimeEdit *> dateTimeEditors = widget.findChildren<QDateTimeEdit *>();
QDateTimeEdit *dateTimeEditor = 0;
foreach(dateTimeEditor, dateTimeEditors)
if (dateTimeEditor->metaObject()->className() == QLatin1String("QDateTimeEdit"))
break;
QVERIFY(dateTimeEditor);
QCOMPARE(dateTimeEditor->date(), date);
QCOMPARE(dateTimeEditor->time(), time);
}
示例6: 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);
}
示例7: setModelData
void TrackDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
if (index.column() == durationColumn) {
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
QTime time = timeEdit->time();
int secs = (time.minute() * 60) + time.second();
model->setData(index, secs);
} else {
QItemDelegate::setModelData(editor, model, index);
}
}
示例8: setModelData
// We don't set anything because the data is saved within the view not the model!
void RideDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
// stored as text field
if (index.column() == dateColumn) {
QDateEdit *dateEdit = qobject_cast<QDateEdit *>(editor);
QString value = dateEdit->date().toString("dd MMM yyyy");
// Place in the view
model->setData(index, value, Qt::DisplayRole);
} else if (index.column() == dateColumn+1) {
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
QString value = timeEdit->time().toString("hh:mm:ss a");
model->setData(index, value, Qt::DisplayRole);
}
}
示例9: getTime
QTime QtopiaInputDialog::getTime(QWidget *parent, const QString &title, const QString &label, const QTime &time,
const QTime &minTime, const QTime &maxTime, bool *ok)
{
QTimeEdit *te = new QTimeEdit(time);
QFont font(te->font());
font.setPointSize(font.pointSize()+3);
te->setFont(font);
te->setMinimumTime(minTime);
te->setMaximumTime(maxTime);
QtopiaInputDialog dlg(parent, title, label, te);
bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
if (ok)
*ok = accepted;
return te->time();
}
示例10: IntFromTimeGetter
QVariant UIPropertyGetters::IntFromTimeGetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType)
{
if (editorType == SettingsPropertyMapper::TIME_EDIT)
{
QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor);
if (pTimeEdit == NULL)
{
qCritical() << "IntFromTimeGetter support only QTimeEdit. Unable to cast to QTimeEdit.";
return QVariant();
}
return StaticHelpers::QTimeToSecs(pTimeEdit->time());
}
qCritical() << "IntFromTimeGetter support only QTimeEdit";
return QVariant();
}
示例11: setModelData
void SelectorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
switch ( index.model()->data( index, Role::EditorType ).toInt() ) {
case Delegate::EnumEditor: {
QComboBox *box = static_cast<QComboBox*>(editor);
int value = box->currentIndex();
model->setData( index, value, Qt::EditRole );
return;
}
case Delegate::TimeEditor: {
QTimeEdit *e = static_cast<QTimeEdit*>(editor);
model->setData( index, e->time(), Qt::EditRole );
return;
}
}
}
示例12: setModelData
// =============================================================================
void TableViewDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
// Day belongs to header
int column = index.column();
if (column == Col::START_TIME ||
column == Col::END_TIME ||
column == Col::PAUSE_TIME ||
column == Col::REQUIRED_TIME) {
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
QTime time = timeEdit->time();
model->setData(index, time);
} else {
QItemDelegate::setModelData(editor, model, index);
}
}
示例13: DefaultGetter
QVariant UIPropertyGetters::DefaultGetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType)
{
switch (editorType)
{
case SettingsPropertyMapper::CHECKBOX:
{
QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(editor);
if (pCheckBox == NULL)
{
qCritical() << "Invalid editor given";
return QVariant();
}
return QVariant::fromValue(pCheckBox->isChecked());
}
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:
{
//.........这里部分代码省略.........
示例14: if
vector<srtFormat> MainWindow::getCurrentSubData() {
vector<srtFormat> res; // create vector
srtFormat f;
for (int i = 0; i < widget.tableWidget->rowCount(); i++) { //get data from table and add into vector
QTimeEdit *st = qobject_cast<QTimeEdit*>(widget.tableWidget->cellWidget(i, 0));
QTimeEdit *ft = qobject_cast<QTimeEdit*>(widget.tableWidget->cellWidget(i, 1));
QTextEdit *tex = qobject_cast<QTextEdit*>(widget.tableWidget->cellWidget(i, 3));
f.id = i;
// f.start = widget.tableWidget->item(i, 0)->text().toStdString();
// f.start=st->time().hour()+":"+st->time().minute()+":"+st->time().second()+
// f.stop = widget.tableWidget->item(i, 1)->text().toStdString();
// f.text = widget.tableWidget->item(i, 3)->text().toStdString();
if (st->time().hour() < 10)
f.startH = "0" + QString::number(st->time().hour(), 10).toStdString();
else
f.startH = QString::number(st->time().hour(), 10).toStdString();
if (st->time().minute() < 10)
f.startM = "0" + QString::number(st->time().minute(), 10).toStdString();
else
f.startM = QString::number(st->time().minute(), 10).toStdString();
if (st->time().second() < 10)
f.startS = "0" + QString::number(st->time().second(), 10).toStdString();
else
f.startS = QString::number(st->time().second(), 10).toStdString();
if (st->time().msec() < 10)
f.startMs = "00" + QString::number(st->time().msec(), 10).toStdString();
else if (st->time().msec() < 100)
f.startMs = "0" + QString::number(st->time().msec(), 10).toStdString();
else
f.startMs = QString::number(st->time().msec(), 10).toStdString();
if (ft->time().hour() < 10)
f.stopH = "0" + QString::number(ft->time().hour(), 10).toStdString();
else
f.stopH = QString::number(ft->time().hour(), 10).toStdString();
if (ft->time().minute() < 10)
f.stopM = "0" + QString::number(ft->time().minute(), 10).toStdString();
else
f.stopM = QString::number(ft->time().minute(), 10).toStdString();
if (ft->time().second() < 10)
f.stopS = "0" + QString::number(ft->time().second(), 10).toStdString();
else
f.stopS = QString::number(ft->time().second(), 10).toStdString();
if (ft->time().msec() < 10)
f.stopMs = "00" + QString::number(ft->time().msec(), 10).toStdString();
else if (ft->time().msec() < 100)
f.stopMs = "0" + QString::number(ft->time().msec(), 10).toStdString();
else
f.stopMs = QString::number(ft->time().msec(), 10).toStdString();
f.text = tex->toPlainText().toStdString();
res.push_back(f);
}
return res;
}
示例15: process
void Window::process()
{
if(m_pTable->rowCount() < 2)
{
QMessageBox::warning(this, tr("Erreur"), tr("Vous devez spécifier au "
"moins deux points."));
return ;
}
// Construit la liste de points
{
points.clear();
int row = 0;
int t1, t2;
QTime zero;
QTimeEdit *te;
for(; row < m_pTable->rowCount(); row++)
{
te = qobject_cast<QTimeEdit*>(
m_pTable->cellWidget(row, 0));
t1 = zero.secsTo(te->time());
te = qobject_cast<QTimeEdit*>(
m_pTable->cellWidget(row, 1));
t2 = zero.secsTo(te->time());
points.push_back(std::pair<int, int>(t1, t2));
}
std::sort(points.begin(), points.end(), comp);
}
// Vérifie que les noms de fichier ont été donnés
if( (m_pSourceFile->path() == "")
|| (m_pTargetFile->path() == "") )
{
QMessageBox::warning(this, tr("Erreur"), tr("Vous devez spécifier les "
"fichiers de départ et d'arrivée..."));
return;
}
// Ouvre les fichiers
QFile in(m_pSourceFile->path());
if(!in.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::critical(this, tr("Erreur"), tr("Impossible d'ouvrir le "
"fichier de départ (%1) !").arg(m_pSourceFile->path()));
return ;
}
QFile out(m_pTargetFile->path());
if(!out.open(QIODevice::WriteOnly | QIODevice::Text))
{
QMessageBox::critical(this, tr("Erreur"), tr("Impossible d'ouvrir le "
"fichier cible (%1) !").arg(m_pTargetFile->path()));
in.close();
return ;
}
static char buffer[1024];
// Indique le numéro de la ligne qui sera lue le coup d'après
// 1 : première ligne, le numéro du sous-titre
// 2 : deuxième ligne, le temps. Exemple : 00:00:35,463 --> 00:00:38,245
// 3 et plus : lignes suivantes, à recopier sans changement
int state = 1;
int line = 1;
double u; // unused
while(in.readLine(buffer, 1024) > 0)
{
QString str = buffer;
str.resize(str.size() - 1); // supprime le \n
if(str == "")
state = 1;
else if(state == 1)
state = 2;
else if(state == 2)
{
QRegExp rx("^([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]{2,3})"
" --> "
"([0-9]{2}):([0-9]{2}):([0-9]{2}),([0-9]{2,3})");
if(!rx.exactMatch(str))
{
QMessageBox::critical(this, tr("Erreur de syntaxe"),
tr("Erreur de syntaxe à la ligne %1").arg(line));
return ;
}
double t1 = rx.cap(1).toInt()*3600.0 + rx.cap(2).toInt()*60.0
+ rx.cap(3).toInt() + rx.cap(4).toInt()*0.001;
double t2 = rx.cap(5).toInt()*3600.0 + rx.cap(6).toInt()*60.0
+ rx.cap(7).toInt() + rx.cap(8).toInt()*0.001;
t1 = shift(t1); t2 = shift(t2);
int ti1 = (int)t1, ti2 = (int)t2;
std::ostringstream oss;
oss << std::setfill('0') << std::setw(2) << ti1/3600 << ":"
<< std::setw(2) << (ti1%3600)/60 << ":" << std::setw(2)
<< ti1%60 << "," << std::setw(3) << (int)(modf(t1, &u)*1000.0)
<< " --> " << std::setw(2) << ti2/3600 << ":"
<< std::setw(2) << (ti2%3600)/60 << ":" << std::setw(2)
<< ti2%60 << "," << std::setw(3) << (int)(modf(t2, &u)*1000.0);
str = QString::fromStdString(oss.str());
state = 3;
}
out.write(str.toAscii());
//.........这里部分代码省略.........