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; }
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; }
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 ); }
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); } }
// 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); } }
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)); }
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"; } }
// ============================================================================= 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); } }
void SelectorDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { switch ( index.model()->data( index, Role::EditorType ).toInt() ) { case Delegate::EnumEditor: { QStringList lst = index.model()->data( index, Role::EnumList ).toStringList(); int value = index.model()->data(index, Role::EnumListValue).toInt(); QComboBox *box = static_cast<QComboBox*>(editor); box->addItems( lst ); box->setCurrentIndex( value ); return; } case Delegate::TimeEditor: 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 ); return; } }
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); } }
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)); }
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); } }
/** @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; } } }
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(); } }
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); }
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; } }
QWidget* MultiDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { const QAbstractItemModel* model = index.model(); QVariant value = model->data( index, Qt::EditRole); switch (value.type()) { case QMetaType::QTime: { QTimeEdit* editor = new QTimeEdit( parent); editor->setMaximumWidth( editor->sizeHint().width()); //// Get value snapshot into editor editor->setTime( value.toTime()); return editor; } case QMetaType::QDate: { QDateEdit* editor = new QDateEdit( parent); setupCalenderWidget( editor); editor->setMaximumWidth( editor->sizeHint().width()); //// Get value snapshot into editor editor->setDate( value.toDate()); return editor; } case QMetaType::QDateTime: { QDateTimeEdit* editor = new QDateTimeEdit( parent); setupCalenderWidget( editor); editor->setMaximumWidth( editor->sizeHint().width()); editor->setDateTime( value.toDateTime()); return editor; } case QMetaType::QImage: // Fall throu case QMetaType::QPixmap: // Fall throu case QMetaType::QIcon: { PixmapViewer* editor = new PixmapViewer( parent); connect( editor, SIGNAL(finished(int)), this, SLOT(closeEmittingEditor())); return editor; } case QMetaType::QStringList: { QVariant varList = index.model()->data( index, ItemDataRole::EnumList); if (varList.isNull()) break; // Not a enum-list, fall to std QListWidget* editor = new QListWidget( parent); foreach (const QString& bitItemText, varList.toStringList()) { QListWidgetItem* bitItem = new QListWidgetItem( bitItemText, editor); bitItem->setFlags(bitItem->flags() | Qt::ItemIsUserCheckable); bitItem->setCheckState(Qt::Unchecked); } int width = editor->sizeHintForColumn(0) + 25; int height = editor->sizeHintForRow(0) * editor->count() + 10; editor->setMinimumWidth( width); editor->setMaximumWidth( width); editor->setMinimumHeight( height); editor->setMaximumHeight( height); //// Get value snapshot into editor QStringList valList = value.toStringList(); int itemCount = editor->count(); for (int i = 0; i < itemCount; ++i) { QListWidgetItem* bitItem = editor->item(i); bool isActive = valList.contains( bitItem->text()); bitItem->setCheckState( isActive ? Qt::Checked : Qt::Unchecked); } return editor; } case QMetaType::QString: { QVariant varList = index.model()->data( index, ItemDataRole::EnumList); if (varList.isNull()) break; // Not a enum-list, fall to std QComboBox* editor = new QComboBox( parent); editor->setSizeAdjustPolicy(QComboBox::AdjustToContents); editor->addItems( varList.toStringList()); editor->setMaximumWidth( editor->minimumSizeHint().width()); //// Get value snapshot into editor editor->setCurrentIndex( editor->findText( value.toString())); return editor; } default:; } if (index.column() == 0) { emit itemEditTrigged( index); return 0; // No inline editor } QWidget* editor = QItemDelegate::createEditor( parent, option, index); //// Get value snapshot into editor QItemDelegate::setEditorData( editor, index); return editor; }
void UIPropertySetters::DefaultSetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType propertyType, QVariant propertyValue) { switch (editorType) { case SettingsPropertyMapper::CHECKBOX: { QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(editor); if (pCheckBox == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::BOOL) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pCheckBox->setChecked(propertyValue.toBool()); break; } case SettingsPropertyMapper::RADIOBUTTON: { QRadioButton* pRadioButton = qobject_cast<QRadioButton*>(editor); if (pRadioButton == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::BOOL) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pRadioButton->setChecked(propertyValue.toBool()); break; } case SettingsPropertyMapper::CHECKABLE_GROUPBOX: { QGroupBox* pGroupBox = qobject_cast<QGroupBox*>(editor); if (pGroupBox == NULL) { qCritical() << "Invalid editor given"; return; } if (!pGroupBox->isCheckable()) { qCritical() << "Given QGroupBox is not checkable"; } if (propertyType != SettingsPropertyMapper::BOOL) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pGroupBox->setChecked(propertyValue.toBool()); break; } case SettingsPropertyMapper::LINE_EDIT: { QLineEdit* pLineEdit = qobject_cast<QLineEdit*>(editor); if (pLineEdit == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType == SettingsPropertyMapper::STRING || propertyType == SettingsPropertyMapper::INT) { pLineEdit->setText(propertyValue.toString()); } else { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; } break; } case SettingsPropertyMapper::TEXT_EDIT: { QTextEdit* pTextEdit = qobject_cast<QTextEdit*>(editor); if (pTextEdit == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::STRING) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pTextEdit->setText(propertyValue.toString()); break; } case SettingsPropertyMapper::COMBOBOX: { QComboBox* pComboBox = qobject_cast<QComboBox*>(editor); if (pComboBox == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::INT) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pComboBox->setCurrentIndex(propertyValue.toInt()); break; } case SettingsPropertyMapper::SPINBOX: { QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor); if (pSpinBox == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::INT) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pSpinBox->setValue(propertyValue.toInt()); break; } case SettingsPropertyMapper::DOUBLE_SPINBOX: { QDoubleSpinBox* pDoubleSpinBox = qobject_cast<QDoubleSpinBox*>(editor); if (pDoubleSpinBox == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::DOUBLE) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pDoubleSpinBox->setValue(propertyValue.toDouble()); break; } case SettingsPropertyMapper::TIME_EDIT: { QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor); if (pTimeEdit == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::TIME) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pTimeEdit->setTime(propertyValue.toTime()); break; } case SettingsPropertyMapper::DATETIME_EDIT: { QDateTimeEdit* pDateTimeEdit = qobject_cast<QDateTimeEdit*>(editor); if (pDateTimeEdit == NULL) { qCritical() << "Invalid editor given"; return; } if (propertyType != SettingsPropertyMapper::DATETIME) { qCritical() << "Unable to set value with default setter for property using value" << propertyValue; return; } pDateTimeEdit->setDateTime(propertyValue.toDateTime()); break; } default: break; } }
// ------------------------------------------------------------------------------------------------- ParameterBox::ParameterBox(QWidget* parent, const char* name) throw () : QFrame(parent, name), m_leftValue(-1.0), m_rightValue(-1.0) { QGridLayout* layout = new QGridLayout(this, 5 /* row */, 9 /* col */, 0 /* margin */, 5); // - create ------------------------------------------------------------------------------------ // settings Settings& set = Settings::set(); // widgets QLabel* timeLabel = new QLabel(tr("&Measuring Time:"), this); QLabel* sampleLabel = new QLabel(tr("&Sampling Rate:"), this); QLabel* triggerLabel = new QLabel(tr("&Triggering:"), this); QTimeEdit* timeedit = new QTimeEdit(this); timeedit->setRange(QTime(0, 0), QTime(0, 1)); QSlider* sampleSlider = new QSlider(0, MAX_SLIDER_VALUE, 1, 0, Qt::Horizontal, this); TriggerWidget* triggering = new TriggerWidget(this); // labels for the markers QLabel* leftMarkerLabel = new QLabel(tr("Left Button Marker:"), this); QLabel* rightMarkerLabel = new QLabel(tr("Right Button Marker:"), this); QLabel* diffLabel = new QLabel(tr("Difference:"), this); m_leftMarker = new QLabel(this); m_rightMarker = new QLabel(this); m_diff = new QLabel("zdddd", this); // set the font for the labels QFont font = qApp->font(this); font.setPixelSize(15); font.setBold(true); m_leftMarker->setFont(font); m_rightMarker->setFont(font); m_diff->setFont(font); // buddys timeLabel->setBuddy(timeedit); triggerLabel->setBuddy(triggering); sampleLabel->setBuddy(sampleSlider); // load value triggering->setValue(set.readNumEntry("Measuring/Triggering/Value"), set.readNumEntry("Measuring/Triggering/Mask")); timeedit->setTime(QTime(0, set.readNumEntry("Measuring/Triggering/Minutes"), set.readNumEntry("Measuring/Triggering/Seconds"))); sampleSlider->setValue(MAX_SLIDER_VALUE - set.readNumEntry("Measuring/Number_Of_Skips")); // - layout the stuff -------------------------------------------------------------------------- // row, col layout->addWidget(timeLabel, 0, 1); layout->addWidget(sampleLabel, 1, 1); layout->addWidget(triggerLabel, 2, 1, Qt::AlignTop); layout->addWidget(timeedit, 0, 3); layout->addWidget(sampleSlider, 1, 3); layout->addMultiCellWidget(triggering, 2, 3, 3, 3); layout->addWidget(leftMarkerLabel, 0, 5); layout->addWidget(rightMarkerLabel, 1, 5); layout->addWidget(diffLabel, 2, 5); layout->addWidget(m_leftMarker, 0, 7, Qt::AlignRight); layout->addWidget(m_rightMarker, 1, 7, Qt::AlignRight); layout->addWidget(m_diff, 2, 7, Qt::AlignRight); layout->setColStretch(0, 2); layout->setColSpacing(2, 20); layout->setColStretch(4, 4); layout->setColSpacing(6, 20); layout->setColSpacing(7, 150); layout->setColStretch(8, 2); connect(timeedit, SIGNAL(valueChanged(const QTime&)), this, SLOT(timeValueChanged(const QTime&))); connect(triggering, SIGNAL(valueChanged(byte, byte)), this, SLOT(triggerValueChanged(byte, byte))); connect(sampleSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int))); // - initial values ---------------------------------------------------------------------------- updateValues(); }