本文整理汇总了C++中QTimeEdit::setTime方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeEdit::setTime方法的具体用法?C++ QTimeEdit::setTime怎么用?C++ QTimeEdit::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimeEdit
的用法示例。
在下文中一共展示了QTimeEdit::setTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createEditor
QWidget* TimeProp::createEditor(QWidget * parent, const QModelIndex & index)
{
Q_UNUSED(index);
QTimeEdit *te = new QTimeEdit(parent);
te->setTime(value().toTime());
connect(te, SIGNAL(timeChanged(const QTime&)), this, SLOT(setValue(const QTime&)));
return te;
}
示例3: setEditorData
void TimeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QTime value = index.model()->data(index, Qt::EditRole).toTime();
QTimeEdit *e = static_cast<QTimeEdit*>(editor);
e->setMinimumTime( index.model()->data( index, Role::Minimum ).toTime() );
e->setMaximumTime( index.model()->data( index, Role::Maximum ).toTime() );
e->setTime( value );
}
示例4: setEditorData
void TrackDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
if (index.column() == durationColumn) {
int secs = index.model()->data(index, Qt::DisplayRole).toInt();
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
timeEdit->setTime(QTime(0, secs / 60, secs % 60));
} else {
QItemDelegate::setEditorData(editor, index);
}
}
示例5: setEditorData
// We don't set anything because the data is saved within the view not the model!
void RideDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
// stored as text field
if (index.column() == dateColumn) {
QDateEdit *dateEdit = qobject_cast<QDateEdit *>(editor);
QDate date = QDate().fromString(index.model()->data(index, Qt::DisplayRole).toString(), "dd MMM yyyy");;
dateEdit->setDate(date);
} else if (index.column() == dateColumn+1) {
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
QTime time = QTime().fromString(index.model()->data(index, Qt::DisplayRole).toString(), "hh:mm:ss a");;
timeEdit->setTime(time);
}
}
示例6: on_subTimeStopCmd_clicked
void MainWindow::on_subTimeStopCmd_clicked() {
qDebug("stop");
int n = widget.tableWidget->currentRow();
if (n < 0) {
return;
}
int t = mpw->getTime();
int ms = t % 1000;
t = t / 1000;
int h = t / 3600;
int m = (t / 60) % 60;
int s = t % 60;
QTimeEdit *q = qobject_cast<QTimeEdit *>(widget.tableWidget->cellWidget(n, 1));
q->setTime(QTime(h, m, s, ms));
}
示例7: TimeFromIntSetter
void UIPropertySetters::TimeFromIntSetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType propertyType, QVariant propertyValue)
{
if (editorType == SettingsPropertyMapper::TIME_EDIT)
{
QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor);
if (pTimeEdit == NULL)
{
qCritical() << "TimeFromIntSetter support only QTimeEdit. Unable to cast to QTimeEdit.";
return;
}
int val = propertyValue.toInt();
pTimeEdit->setTime(StaticHelpers::SecsToQTime(val));
}
else
{
qCritical() << "SpinboxKBSetter support only QSpinBox";
}
}
示例8: setEditorData
// =============================================================================
void TableViewDelegate::setEditorData(QWidget *editor,
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) {
QTime time = index.model()->data(index, Qt::DisplayRole).toTime();
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
timeEdit->setTime(time);
} else {
QItemDelegate::setEditorData(editor, index);
}
}
示例9: setEditorData
void TrackDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
if ( !index.isValid()) {
return;
}
QTimeEdit* timeEditor = qobject_cast<QTimeEdit*>(editor);
if ( !timeEditor) {
return;
}
if (isRightColumn(index, TrackDelegate::columnNumber)) {
int secs = index.model()->data(index, Qt::EditRole).toInt();
QTime time(secs / 60, secs % 60);
timeEditor->setTime(time);
} else {
QStyledItemDelegate::setEditorData(editor, index);
}
}
示例10: on_subTimeStartCmd_clicked
void MainWindow::on_subTimeStartCmd_clicked() {
qDebug("start");
int n = widget.tableWidget->currentRow();
if (n < 0) {
return;
}
// widget.textEdit->setText(QString::number(mpw->getTime()));
int t = mpw->getTime();
int ms = t % 1000;
t = t / 1000;
int h = t / 3600;
int m = (t / 60) % 60;
int s = t % 60;
cout<<t<<" "<<n<<endl;
QTimeEdit *q = qobject_cast<QTimeEdit *>(widget.tableWidget->cellWidget(n, 0));
QTimeEdit *q2 = qobject_cast<QTimeEdit *>(widget.tableWidget->cellWidget(n, 1));
q->setTime(QTime(h, m, s, ms));
// q2->setTime(QTime(h, m, s, ms));
}
示例11: 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);
}
}
示例12: configToWidget
/**
@brief Initialise un widget avec une liste de parametres
@param widget Widget parent
@param list Liste des parametres
@remarks Les noms des widgets doivent correspondres avec les noms de paramètres
*/
void Configurable::configToWidget(QObject* widget,ConfigParamList& list){
//scan les elements enfants
for(ConfigParamList::const_iterator cur = list.begin(); cur != list.end(); cur++){
QString name = cur->first;
QString value = cur->second->getValue();
QWidget* child = widget->findChild<QWidget*>(name);
if(child==0){
QPRINT("configToWidget: "+name+" not found");
continue;
}
// QLineEdit ?
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(child);
if(lineEdit){
lineEdit->setText(value);
continue;
}
// QComboBox ?
QComboBox *comboBox = qobject_cast<QComboBox *>(child);
if(comboBox){
comboBox->setCurrentIndex(comboBox->findText(value));
continue;
}
// QSpinBox ?
QSpinBox *spinBox = qobject_cast<QSpinBox *>(child);
if(spinBox){
spinBox->setValue(value.toInt());
continue;
}
// QDoubleSpinBox ?
QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox *>(child);
if(doubleSpinBox){
doubleSpinBox->setValue(value.toInt());
continue;
}
// QTextEdit ?
QTextEdit *textEdit = qobject_cast<QTextEdit *>(child);
if(textEdit){
textEdit->setPlainText(value);
continue;
}
// QPlainTextEdit ?
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(child);
if(plainTextEdit){
plainTextEdit->setPlainText(value);
continue;
}
// QTimeEdit ?
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(child);
if(timeEdit){
timeEdit->setTime(QTime::fromString(value));
continue;
}
// QDateTimeEdit ?
QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit *>(child);
if(dateTimeEdit){
timeEdit->setDateTime(QDateTime::fromString(value));
continue;
}
// QDateEdit ?
QDateEdit *dateEdit = qobject_cast<QDateEdit *>(child);
if(dateEdit){
dateEdit->setDate(QDate::fromString(value));
continue;
}
// QDial ?
QDial *dial = qobject_cast<QDial *>(child);
if(dial){
dial->setValue(value.toInt());
continue;
}
// QSlider ?
QSlider *slider = qobject_cast<QSlider *>(child);
if(slider){
slider->setValue(value.toInt());
continue;
}
}
}
示例13: 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();
}
}
示例14: 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);
// The data must actually be different in order for the model
// to be updated.
timeEditor->setTime(time.addSecs(60));
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);
dateEditor->setDate(date.addDays(60));
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);
dateTimeEditor->setTime(time.addSecs(600));
widget.clearFocus();
QVERIFY(item1->data(Qt::EditRole).userType() == QMetaType::QTime);
QVERIFY(item2->data(Qt::EditRole).userType() == QMetaType::QDate);
QVERIFY(item3->data(Qt::EditRole).userType() == QMetaType::QDateTime);
}
示例15: setEditorData
void PupilContActivityDelegate::setEditorData ( QWidget *editor, const QModelIndex &index ) const
{
switch ( index.column() ) {
case 2: {
QComboBox *combo = qobject_cast<QComboBox *> ( editor );
if ( !combo ) {
QItemDelegate::setEditorData ( editor, index );
return;
}
int pos = combo->findText(index.model()->data(index).toString(), Qt::MatchExactly );
if(pos == -1) {
combo->addItem(index.model()->data(index).toString());
combo->findText(index.model()->data(index).toString(), Qt::MatchExactly );
}
combo->setCurrentIndex(pos);
}
case 3: {
QComboBox *combo = qobject_cast<QComboBox *> ( editor );
if ( !combo ) {
QItemDelegate::setEditorData ( editor, index );
return;
}
int pos = combo->findText(index.model()->data(index).toString(), Qt::MatchExactly );
if(pos == -1) {
combo->addItem(index.model()->data(index).toString());
combo->findText(index.model()->data(index).toString(), Qt::MatchExactly );
}
combo->setCurrentIndex(pos);
}
break;
case 4: {
QTimeEdit *time = qobject_cast<QTimeEdit *> ( editor );
if ( !time ) {
QItemDelegate::setEditorData ( editor, index );
return;
}
time->setTime ( QTime::fromString ( index.model()->data(index).toString(),"hh:mm" ) );
}
break;
case 5: {
QDateEdit *cal = qobject_cast<QDateEdit *> ( editor );
if ( !cal ) {
QItemDelegate::setEditorData ( editor, index );
return;
}
cal->setDate ( QDate::fromString ( index.model()->data(index).toString(),"dd.MM.yyyy" ) );
}
break;
case 6: {
QDateEdit *cal1 = qobject_cast<QDateEdit *> ( editor );
if ( !cal1 ) {
QItemDelegate::setEditorData ( editor, index );
return;
}
if(index.model()->data(index).toString() == "") cal1->setDate ( QDate::currentDate() );
else cal1->setDate ( QDate::fromString ( index.model()->data(index).toString(),"dd.MM.yyyy" ) );
}
break;
default: {
QItemDelegate::setEditorData ( editor, index );
return;
}
break;
}
}