本文整理汇总了C++中QTimeEdit::setDisplayFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeEdit::setDisplayFormat方法的具体用法?C++ QTimeEdit::setDisplayFormat怎么用?C++ QTimeEdit::setDisplayFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimeEdit
的用法示例。
在下文中一共展示了QTimeEdit::setDisplayFormat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QTimeEdit
void
MetaQueryWidget::makeLengthSelection()
{
QTimeEdit* timeSpin = new QTimeEdit();
timeSpin->setDisplayFormat( "m:ss" );
timeSpin->setMinimumTime( QTime( 0, 0, 0 ) );
timeSpin->setMaximumTime( QTime( 0, 60, 59) );
timeSpin->setTime( QTime().addSecs( m_filter.numValue ) );
connect( timeSpin, SIGNAL(timeChanged(const QTime&)),
SLOT(numValueChanged(const QTime&)) );
m_valueSelection1 = timeSpin;
if( m_filter.condition != Between )
return;
QTimeEdit* timeSpin2 = new QTimeEdit();
timeSpin2->setDisplayFormat( "m:ss" );
timeSpin2->setMinimumTime( QTime( 0, 0, 0 ) );
timeSpin2->setMaximumTime( QTime( 0, 60, 59) );
timeSpin2->setTime( QTime().addSecs( m_filter.numValue2 ) );
connect( timeSpin2, SIGNAL(timeChanged(const QTime&)),
SLOT(numValueChanged(const QTime&)) );
m_valueSelection2 = timeSpin2;
}
示例2: addRow
void MainWindow::addRow(bool isUp) {
int n = widget.tableWidget->currentRow();
// qDebug(QString::number(n).toStdString().c_str());
if (isUp) {
// n;
} else {
n++;
}
if (n < 0) {
n = 0;
}
widget.tableWidget->insertRow(n);
QTimeEdit *st = new QTimeEdit(widget.tableWidget);
st->setDisplayFormat("HH:mm:ss.zzz");
QTimeEdit *ft = new QTimeEdit(widget.tableWidget);
ft->setDisplayFormat("HH:mm:ss.zzz");
QTextEdit *edit = new QTextEdit(widget.tableWidget);
QSpinBox *spin = new QSpinBox(widget.tableWidget);
spin->setRange(0, 100000);
QObject::connect(st, SIGNAL(timeChanged(QTime)), this, SLOT(timesChanged(QTime)));
QObject::connect(ft, SIGNAL(timeChanged(QTime)), this, SLOT(timesChanged(QTime)));
// widget.tableWidget->model()
widget.tableWidget->setCellWidget(n, 0, st);
widget.tableWidget->setCellWidget(n, 1, ft);
widget.tableWidget->setCellWidget(n, 2, spin);
widget.tableWidget->setCellWidget(n, 3, edit);
// widget.tableWidget->row(st);
}
示例3: createEditor
QWidget *TrackDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == durationColumn) {
QTimeEdit *timeEdit = new QTimeEdit(parent);
timeEdit->setDisplayFormat("mm:ss");
connect(timeEdit, SIGNAL(editingFinished()),
this, SLOT(commitAndCloseEditor()));
return timeEdit;
} else {
return QItemDelegate::createEditor(parent, option, index);
}
}
示例4: createEditor
// setup editor for edit of field!!
QWidget *RideDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() == dateColumn) {
// edit that date!
QDateEdit *dateEdit = new QDateEdit(parent);
dateEdit->setDisplayFormat("dd MMM yyyy");
connect(dateEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseDateEditor()));
return dateEdit;
} else if (index.column() == dateColumn+1) {
// edit that time
QTimeEdit *timeEdit = new QTimeEdit(parent);
timeEdit->setDisplayFormat("hh:mm:ss a");
connect(timeEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseTimeEditor()));
return timeEdit;
} else {
return QItemDelegate::createEditor(parent, option, index);
}
}
示例5: createEditor
// =============================================================================
QWidget *TableViewDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
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 = new QTimeEdit(parent);
timeEdit->setDisplayFormat("hh:mm");
connect(timeEdit, SIGNAL(editingFinished()),
this, SLOT(commitAndCloseTimeEdit()));
return timeEdit;
} else {
return QItemDelegate::createEditor(parent, option, index);
}
}
示例6: createEditor
QWidget* TrackDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (isRightColumn(index, TrackDelegate::columnNumber))
{
QTimeEdit *timeEdit = new QTimeEdit(parent);
timeEdit->setDisplayFormat("hh:mm");
connect(timeEdit, &QTimeEdit::editingFinished,
this, &TrackDelegate::commitAndCloseEditor);
//int secs = index.model()->data(index, Qt::DisplayRole).toInt();
int secs = index.model()->data(index, Qt::EditRole).toInt();
QTime time(secs / 60, secs % 60);
timeEdit->setTime(time);
return timeEdit;
}
else
{
return QStyledItemDelegate::createEditor(parent, option, index);
}
}
示例7: setSubtitle
void MainWindow::setSubtitle(vector<srtFormat> vv) {
subList = vv;
//addToGraph(); // draw data on graph as thread function
widget.tableWidget->setRowCount(0); // clear the exsisting subtitles
long st;
long et;
long dt;
int sH, fH;
int sM, fM;
int sS, fS;
int sMs, fMs;
//add subtitle component as appropriate
//QMessageBox *msgBox = new QMessageBox(this);
QString lString("HelloWorld");
QMessageBox msgBox(QMessageBox::Information, QString("HelloWorld"), (lString), QMessageBox::NoButton, this);
for (int i = 0; i < (signed int) subList.size(); i++) {
srtFormat srt = subList.at(i);
widget.tableWidget->insertRow(i);
QString s = QString::fromStdString(srt.text);
st = (atoi(srt.startH.c_str())*3600 + atoi(srt.startM.c_str())*60 + atoi(srt.startS.c_str()))*1000 + atoi(srt.startMs.c_str());
et = (atoi(srt.stopH.c_str())*3600 + atoi(srt.stopM.c_str())*60 + atoi(srt.stopS.c_str()))*1000 + atoi(srt.stopMs.c_str());
// QString sTime = QString::fromStdString(srt.startH + ":" + srt.startM + ":" + srt.startS + "," + srt.startMs);
// QString eTime = QString::fromStdString(srt.stopH + ":" + srt.stopM + ":" + srt.stopS + "," + srt.stopMs);
dt = et - st;
sH = QString::fromStdString(srt.startH).toInt();
sM = QString::fromStdString(srt.startM).toInt();
sS = QString::fromStdString(srt.startS).toInt();
sMs = QString::fromStdString(srt.startMs).toInt();
fH = QString::fromStdString(srt.stopH).toInt();
fM = QString::fromStdString(srt.stopM).toInt();
fS = QString::fromStdString(srt.stopS).toInt();
fMs = QString::fromStdString(srt.stopMs).toInt();
QTimeEdit *st = new QTimeEdit(widget.tableWidget);
st->setDisplayFormat("HH:mm:ss.zzz");
st->setTime(QTime(sH, sM, sS, sMs));
QTimeEdit *ft = new QTimeEdit(widget.tableWidget);
ft->setDisplayFormat("HH:mm:ss.zzz");
ft->setTime(QTime(fH, fM, fS, fMs));
QTextEdit *edit = new QTextEdit(widget.tableWidget);
edit->setText(s.trimmed().simplified());
QSpinBox *spin = new QSpinBox(widget.tableWidget);
spin->setRange(0, 100000);
spin->setValue(dt);
QObject::connect(st, SIGNAL(timeChanged(QTime)), this, SLOT(timesChanged(QTime)));
QObject::connect(ft, SIGNAL(timeChanged(QTime)), this, SLOT(timesChanged(QTime)));
widget.tableWidget->setCellWidget(i, 0, st);
widget.tableWidget->setCellWidget(i, 1, ft);
widget.tableWidget->setCellWidget(i, 2, spin);
widget.tableWidget->setCellWidget(i, 3, edit);
cout << (i * 100) / subList.size() << " %\r";
cout.flush();
// msgBox.setText(QString::number((i * 100) / subList.size()));
// widget.textEdit->setText(QString::number((i * 100) / subList.size()));
// msgBox->setText("rukshan");
// msgBox.show();
}
}