本文整理汇总了C++中QComboBox::currentIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::currentIndex方法的具体用法?C++ QComboBox::currentIndex怎么用?C++ QComboBox::currentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::currentIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newdat
//-----------------------------------------------------------------------------
void DatPanel::newdat()
{
QLabel *l;
QLineEdit *f1, *f2;
QPushButton *b;
QDialog *d = new QDialog(this);
d->setWindowTitle(tr("UDAV - make new data"));
QVBoxLayout *v = new QVBoxLayout(d);
QComboBox *c = new QComboBox(d); v->addWidget(c);
c->addItem(tr("Sum along direction(s)"));
c->addItem(tr("Min along direction(s)"));
c->addItem(tr("Max along direction(s)"));
c->addItem(tr("Momentum along 'x' for function"));
c->addItem(tr("Momentum along 'y' for function"));
c->addItem(tr("Momentum along 'z' for function"));
c->setCurrentIndex(0);
f1 = new QLineEdit("z",d); v->addWidget(f1);
QCheckBox *cb = new QCheckBox(tr("Put into this data array"), d); v->addWidget(cb);
l = new QLabel(tr("or enter name for new variable"), d); v->addWidget(l);
f2 = new QLineEdit(d); v->addWidget(f2);
QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1);
b = new QPushButton(tr("Cancel"), d); h->addWidget(b);
connect(b, SIGNAL(clicked()), d, SLOT(reject()));
b = new QPushButton(tr("OK"), d); h->addWidget(b);
connect(b, SIGNAL(clicked()), d, SLOT(accept()));
b->setDefault(true);
// now execute dialog and get values
bool res = d->exec();
QString val = f1->text(), mgl;
int k = c->currentIndex();
QString self = QString::fromWCharArray(var->s.c_str());
if(res)
{
if(k<0)
{
QMessageBox::warning(d, tr("UDAV - make new data"),
tr("No action is selected. Do nothing."));
return;
}
if(val.isEmpty())
{
QMessageBox::warning(d, tr("UDAV - make new data"),
tr("No direction/formula is entered. Do nothing."));
return;
}
if(cb->isChecked()) k += 6;
QString name = f2->text();
switch(k)
{
case 0: mgl = "sum "+name+" "+self+" '"+val+"'"; break;
case 1: mgl = "min "+name+" "+self+" '"+val+"'"; break;
case 2: mgl = "max "+name+" "+self+" '"+val+"'"; break;
case 3: mgl = "momentum "+name+" "+self+" 'x' '"+val+"'"; break;
case 4: mgl = "momentum "+name+" "+self+" 'y' '"+val+"'"; break;
case 5: mgl = "momentum "+name+" "+self+" 'z' '"+val+"'"; break;
case 6: mgl = "copy "+self+" {sum "+self+" '"+val+"'}"; break;
case 7: mgl = "copy "+self+" {min "+self+" '"+val+"'}"; break;
case 8: mgl = "copy "+self+" {max "+self+" '"+val+"'}"; break;
case 9: mgl = "copy "+self+" {momentum "+self+" 'x' '"+val+"'}"; break;
case 10: mgl = "copy "+self+" {momentum "+self+" 'y' '"+val+"'}"; break;
case 11: mgl = "copy "+self+" {momentum "+self+" 'z' '"+val+"'}"; break;
}
}
if(!mgl.isEmpty())
{
mglGraph gr;
parser.Execute(&gr,mgl.toLocal8Bit().constData());
if(k>=6) opers += mgl+"\n";
updateDataItems();
}
}
示例2: 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:
{
//.........这里部分代码省略.........
示例3: setupUi
//.........这里部分代码省略.........
subMenu = new QMenu(tr("Speed"));
mpMenu->addMenu(subMenu);
QDoubleSpinBox *pSpeedBox = new QDoubleSpinBox(0);
pSpeedBox->setRange(0.01, 20);
pSpeedBox->setValue(1.0);
pSpeedBox->setSingleStep(0.01);
pSpeedBox->setCorrectionMode(QAbstractSpinBox::CorrectToPreviousValue);
pWA = new QWidgetAction(0);
pWA->setDefaultWidget(pSpeedBox);
subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
subMenu = new ClickableMenu(tr("Repeat"));
mpMenu->addMenu(subMenu);
//subMenu->setEnabled(false);
mpRepeatEnableAction = subMenu->addAction(tr("Enable"));
mpRepeatEnableAction->setCheckable(true);
connect(mpRepeatEnableAction, SIGNAL(toggled(bool)), SLOT(toggleRepeat(bool)));
// TODO: move to a func or class
mpRepeatBox = new QSpinBox(0);
mpRepeatBox->setMinimum(-1);
mpRepeatBox->setValue(-1);
mpRepeatBox->setToolTip("-1: " + tr("infinity"));
connect(mpRepeatBox, SIGNAL(valueChanged(int)), SLOT(setRepeateMax(int)));
QLabel *pRepeatLabel = new QLabel(tr("Times"));
QHBoxLayout *hb = new QHBoxLayout;
hb->addWidget(pRepeatLabel);
hb->addWidget(mpRepeatBox);
QVBoxLayout *vb = new QVBoxLayout;
vb->addLayout(hb);
pRepeatLabel = new QLabel(tr("From"));
mpRepeatA = new QTimeEdit();
mpRepeatA->setDisplayFormat("HH:mm:ss");
mpRepeatA->setToolTip(tr("negative value means from the end"));
connect(mpRepeatA, SIGNAL(timeChanged(QTime)), SLOT(repeatAChanged(QTime)));
hb = new QHBoxLayout;
hb->addWidget(pRepeatLabel);
hb->addWidget(mpRepeatA);
vb->addLayout(hb);
pRepeatLabel = new QLabel(tr("To"));
mpRepeatB = new QTimeEdit();
mpRepeatB->setDisplayFormat("HH:mm:ss");
mpRepeatB->setToolTip(tr("negative value means from the end"));
connect(mpRepeatB, SIGNAL(timeChanged(QTime)), SLOT(repeatBChanged(QTime)));
hb = new QHBoxLayout;
hb->addWidget(pRepeatLabel);
hb->addWidget(mpRepeatB);
vb->addLayout(hb);
QWidget *wgt = new QWidget;
wgt->setLayout(vb);
pWA = new QWidgetAction(0);
pWA->setDefaultWidget(wgt);
pWA->defaultWidget()->setEnabled(false);
subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
mpRepeatAction = pWA;
mpMenu->addSeparator();
subMenu = new ClickableMenu(tr("Subtitle"));
mpMenu->addMenu(subMenu);
QAction *act = subMenu->addAction(tr("Enable"));
act->setCheckable(true);
act->setChecked(mpSubtitle->isEnabled());
connect(act, SIGNAL(toggled(bool)), SLOT(toggoleSubtitleEnabled(bool)));
act = subMenu->addAction(tr("Auto load"));
act->setCheckable(true);
act->setChecked(mpSubtitle->autoLoad());
connect(act, SIGNAL(toggled(bool)), SLOT(toggleSubtitleAutoLoad(bool)));
subMenu->addAction(tr("Open"), this, SLOT(openSubtitle()));
wgt = new QWidget();
hb = new QHBoxLayout();
wgt->setLayout(hb);
hb->addWidget(new QLabel(tr("Engine")));
QComboBox *box = new QComboBox();
hb->addWidget(box);
pWA = new QWidgetAction(0);
pWA->setDefaultWidget(wgt);
subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
box->addItem("FFmpeg", "FFmpeg");
box->addItem("LibASS", "LibASS");
connect(box, SIGNAL(activated(QString)), SLOT(setSubtitleEngine(QString)));
mpSubtitle->setEngines(QStringList() << box->itemData(box->currentIndex()).toString());
box->setToolTip(tr("FFmpeg supports more subtitles but only render plain text") + "\n" + tr("LibASS supports ass styles"));
wgt = new QWidget();
hb = new QHBoxLayout();
wgt->setLayout(hb);
hb->addWidget(new QLabel(tr("Charset")));
box = new QComboBox();
hb->addWidget(box);
pWA = new QWidgetAction(0);
pWA->setDefaultWidget(wgt);
subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
box->addItem(tr("Auto detect"), "AutoDetect");
box->addItem(tr("System"), "System");
foreach (const QByteArray& cs, QTextCodec::availableCodecs()) {
box->addItem(cs, cs);
}
示例4: preferencesDialog
void ActionZone::preferencesDialog() {
QSettings settings("otter", "dict");
QDialog * dialog = new QDialog();
QPushButton * okButton = new QPushButton("OK", dialog);
connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
QPushButton * cancelButton = new QPushButton("Cancel", dialog);
connect(cancelButton, SIGNAL(clicked()), dialog, SLOT(reject()));
QBoxLayout * buttonLayout = new QHBoxLayout();
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
QLabel * dictionaryCountLabel = new QLabel("Number of dictionaries", dialog);
QComboBox * dictionaryCountCombo = new QComboBox(dialog);
dictionaryCountCombo->addItem("1");
dictionaryCountCombo->addItem("2");
dictionaryCountCombo->addItem("3");
dictionaryCountCombo->addItem("4");
dictionaryCountCombo->addItem("5");
dictionaryCountCombo->setCurrentIndex(resultViewers_.size() - 1);
QLabel * pluginDirectoryLabel = new QLabel("Directory with plugins", dialog);
QLineEdit * pluginDirectory = new QLineEdit(dialog);
{
QString directories;
settings.beginGroup("application");
int size = settings.beginReadArray("plugindirectory");
for (int i = 0; i < size; i++) {
settings.setArrayIndex(i);
QString dir = settings.value("directory").toString();
if (dir.isEmpty()) {
continue;
}
directories += dir + ":";
}
pluginDirectory->setText(directories);
settings.endArray();
settings.endGroup();
}
QLabel * reloadInfoLabel = new QLabel(
"OtterDict needs to be restarted to apply the changes.", dialog);
reloadInfoLabel->setWordWrap(true);
reloadInfoLabel->setFrameShape(QFrame::StyledPanel);
QGridLayout * preferencesLayout = new QGridLayout(dialog);
preferencesLayout->setSizeConstraint(QLayout::SetFixedSize);
preferencesLayout->addWidget(dictionaryCountLabel, 0, 0, Qt::AlignRight);
preferencesLayout->addWidget(dictionaryCountCombo, 0, 1, Qt::AlignLeft);
preferencesLayout->addWidget(pluginDirectoryLabel, 1, 0, Qt::AlignRight);
preferencesLayout->addWidget(pluginDirectory, 1, 1, Qt::AlignLeft);
preferencesLayout->addWidget(reloadInfoLabel, 2, 0, 1, 2, Qt::AlignHCenter);
preferencesLayout->addLayout(buttonLayout, 3, 0, 1, 2, Qt::AlignHCenter);
dialog->setSizeGripEnabled(false);
dialog->setWindowTitle("OtterDict preferences");
QDialog::DialogCode retCode = (QDialog::DialogCode)dialog->exec();
if (retCode == QDialog::Rejected) {
return;
}
int dictionaryCount = dictionaryCountCombo->currentIndex() + 1;
settings.setValue("mainwindow/dictionarycount", dictionaryCount);
// Write the application settings.
settings.beginGroup("application");
// Write the plugin directories.
{
settings.beginWriteArray("plugindirectory");
QStringList dirs = pluginDirectory->text().split(":", QString::SkipEmptyParts);
QStringList::iterator e = dirs.end();
int idx;
QStringList::iterator i;
for (idx = 0, i = dirs.begin(); i != e; ++i, idx++) {
settings.setArrayIndex(idx);
settings.setValue("directory", *i);
}
settings.endArray();
}
settings.endGroup();
}
示例5: setModelData
// Запись данных в модель
void ComboBoxMailDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)const
{
QComboBox* pRes = dynamic_cast<QComboBox*>(editor);
if (pRes) {
if (index.column() == 1) {
QString pole = index.model()->data(index.sibling(index.row(), 0)).toString();
int j;
for (int i = 0; i < fieldName.count(); i++) {
QString s = this->model->headerData(fieldName.at(i) , Qt::Horizontal).toString();
s.replace("\n", " ");
if (s == pole) {
j = fieldName.at(i);
break;
}
}
if (this->model->data(this->model->index(0, j), Qt::EditRole).type() == QVariant::Bool) {
model->setData(index, pRes->currentIndex(), Qt::EditRole);
return;
}
QString str = pRes->model()->data(pRes->model()->index(pRes->currentIndex(), 0)).toString();
model->setData(index, str, Qt::EditRole);
}
else {
QString str = pRes->currentText();
model->setData(index, str, Qt::EditRole);
if (index.column() == 0)
model->setData(index.sibling(index.row(), 1), "", Qt::EditRole);
// Добавление строки
bool spaceflag = false;
for (int i = 0; i < index.model()->rowCount(); i++) {
QString valstr = index.model()->data(index.sibling(i, 0)).toString();
if (valstr == tr("")) {
spaceflag = true;
break;
}
}
if (spaceflag == false) {
int row = index.model()->rowCount();
if (row < 0)
row = 0;
model->insertRow(row);
model->submit();
}
}
}
else {
QItemDelegate::setModelData(editor, model, index);
}
};
示例6: setModelData
void QgsComposerColumnAlignmentDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const
{
QComboBox *comboBox = static_cast<QComboBox*>( editor );
Qt::AlignmentFlag alignment = ( Qt::AlignmentFlag ) comboBox->itemData( comboBox->currentIndex() ).toInt();
model->setData( index, alignment, Qt::EditRole );
}
示例7: SynchronizeInterfaceWindow
//.........这里部分代码省略.........
if (type == QString("colorpalette"))
{
if (mode == read)
{
cColorPalette palette = colorPaletteWidget->GetPalette();
par->Set(parameterName, palette);
}
else if (mode == write)
{
cColorPalette palette = par->Get<cColorPalette>(parameterName);
colorPaletteWidget->SetPalette(palette);
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: QComboBox", 3);
//combo boxes
{
QList<QComboBox *> widgetListPushButton = window->findChildren<QComboBox*>();
QList<QComboBox *>::iterator it;
for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it)
{
QString name = (*it)->objectName();
//qDebug() << "QComboBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
if (name.length() > 1 && (*it)->metaObject()->className() == QString("QComboBox"))
{
QComboBox *comboBox = *it;
QString type, parameterName;
GetNameAndType(name, ¶meterName, &type);
if (type == QString("comboBox"))
{
if (mode == read)
{
int selection = comboBox->currentIndex();
if (parameterName.left(7) == QString("formula"))
{
selection = fractalList[comboBox->itemData(selection).toInt()].internalID;
}
par->Set(parameterName, selection);
}
else if (mode == write)
{
int selection = par->Get<int>(parameterName);
if (parameterName.left(7) == QString("formula"))
{
for (int i = 0; i < fractalList.size(); i++)
{
if (fractalList[i].internalID == selection)
{
selection = comboBox->findData(i);
break;
}
}
}
comboBox->setCurrentIndex(selection);
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: cMaterialSelector", 3);
//---------- material selector -----------
{
QList<cMaterialSelector *> widgetListMaterialSelector =
window->findChildren<cMaterialSelector*>();
QList<cMaterialSelector *>::iterator it;
for (it = widgetListMaterialSelector.begin(); it != widgetListMaterialSelector.end(); ++it)
{
QString name = (*it)->objectName();
// QString className = (*it)->metaObject()->className();
if (name.length() > 1 && (*it)->metaObject()->className() == QString("cMaterialSelector"))
{
QString type, parameterName;
GetNameAndType(name, ¶meterName, &type);
cMaterialSelector *materialSelector = *it;
materialSelector->AssignParameterContainer(par);
materialSelector->AssingParameterName(parameterName);
if (type == QString("materialselector"))
{
if (mode == read)
{
par->Set(parameterName, materialSelector->GetMaterialIndex());
}
else if (mode == write)
{
materialSelector->SetMaterialIndex(par->Get<int>(parameterName));
}
}
}
}
}
WriteLog("cInterface::SynchronizeInterface: Done", 3);
}
示例8: retrieveValue
bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value )
{
if ( !widget )
return false;
const QgsField &theField = vl->pendingFields()[idx];
QgsVectorLayer::EditType editType = vl->editType( idx );
bool modified = false;
QString text;
QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
QLineEdit *le = qobject_cast<QLineEdit *>( widget );
if ( le )
{
text = le->text();
modified = le->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
if ( te )
{
text = te->toHtml();
modified = te->document()->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
if ( pte )
{
text = pte->toPlainText();
modified = pte->document()->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QComboBox *cb = qobject_cast<QComboBox *>( widget );
if ( cb )
{
if ( editType == QgsVectorLayer::UniqueValues ||
editType == QgsVectorLayer::ValueMap ||
editType == QgsVectorLayer::Classification ||
editType == QgsVectorLayer::ValueRelation )
{
text = cb->itemData( cb->currentIndex() ).toString();
if ( text == nullValue )
{
text = QString::null;
}
}
else
{
text = cb->currentText();
}
modified = true;
}
QListWidget *lw = qobject_cast<QListWidget *>( widget );
if ( lw )
{
if ( editType == QgsVectorLayer::ValueRelation )
{
text = '{';
for ( int i = 0, n = 0; i < lw->count(); i++ )
{
if ( lw->item( i )->checkState() == Qt::Checked )
{
if ( n > 0 )
{
text.append( ',' );
}
text.append( lw->item( i )->data( Qt::UserRole ).toString() );
n++;
}
}
text.append( '}' );
}
else
{
text = QString::null;
}
modified = true;
}
QSpinBox *sb = qobject_cast<QSpinBox *>( widget );
if ( sb )
{
text = QString::number( sb->value() );
}
//.........这里部分代码省略.........
示例9: setModelData
//===========================
void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *combo = static_cast<QComboBox*>(editor);
int value = combo->currentIndex();
model->setData(index, value);
}
示例10: load
void DesignerFields::load( DesignerFields::Storage *storage )
{
QStringList keys = storage->keys();
// clear all custom page widgets
// we can't do this in the following loop, as it works on the
// custom fields of the vcard, which may not be set.
QMap<QString, QWidget *>::ConstIterator widIt;
for ( widIt = mWidgets.constBegin(); widIt != mWidgets.constEnd(); ++widIt ) {
QString value;
if ( widIt.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( widIt.value() );
wdg->setText( QString() );
} else if ( widIt.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( widIt.value() );
wdg->setValue( wdg->minimum() );
} else if ( widIt.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( widIt.value() );
wdg->setChecked( false );
} else if ( widIt.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( widIt.value() );
wdg->setDate( QDate::currentDate() );
} else if ( widIt.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( widIt.value() );
wdg->setCurrentIndex( 0 );
} else if ( widIt.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( widIt.value() );
wdg->setPlainText( QString() );
}
}
QStringList::ConstIterator it2;
for ( it2 = keys.constBegin(); it2 != keys.constEnd(); ++it2 ) {
QString value = storage->read( *it2 );
QMap<QString, QWidget *>::ConstIterator it = mWidgets.constFind( *it2 );
if ( it != mWidgets.constEnd() ) {
if ( it.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( it.value() );
wdg->setText( value );
} else if ( it.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( it.value() );
wdg->setValue( value.toInt() );
} else if ( it.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( it.value() );
wdg->setChecked( value == "true" || value == "1" );
} else if ( it.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( it.value() );
wdg->setDate( QDate::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( it.value() );
wdg->setItemText( wdg->currentIndex(), value );
} else if ( it.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( it.value() );
wdg->setPlainText( value );
}
}
}
}
示例11: apply
void QgsVectorLayerProperties::apply()
{
//
// Set up sql subset query if applicable
//
#ifdef HAVE_POSTGRESQL
//see if we are dealing with a pg layer here
if ( layer->providerType() == "postgres" )
{
grpSubset->setEnabled( true );
// set the subset sql for the layer
layer->setSubsetString( txtSubsetSQL->toPlainText() );
// update the metadata with the updated sql subset
QString myStyle = QgsApplication::reportStyleSheet();
teMetadata->clear();
teMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadata->setHtml( metadata() );
// update the extents of the layer (fetched from the provider)
layer->updateExtents();
}
#endif
// set up the scale based layer visibility stuff....
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinimumScale( spinMinimumScale->value() );
layer->setMaximumScale( spinMaximumScale->value() );
// update the display field
layer->setDisplayField( displayFieldComboBox->currentText() );
actionDialog->apply();
labelDialog->apply();
layer->enableLabels( labelCheckBox->isChecked() );
layer->setLayerName( displayName() );
for ( int i = 0; i < tblAttributes->rowCount(); i++ )
{
int idx = tblAttributes->item( i, 0 )->text().toInt();
const QgsField &field = layer->pendingFields()[idx];
QComboBox *cb = dynamic_cast<QComboBox*>( tblAttributes->cellWidget( i, 6 ) );
if ( !cb )
continue;
QgsVectorLayer::EditType editType = ( QgsVectorLayer::EditType ) cb->itemData( cb->currentIndex() ).toInt();
layer->setEditType( idx, editType );
QString value = tblAttributes->item( i, 7 ) ? tblAttributes->item( i, 7 )->text() : QString::null;
if ( editType == QgsVectorLayer::ValueMap )
{
QMap<QString, QVariant> &map = layer->valueMap( idx );
map.clear();
if ( !value.isEmpty() )
{
QStringList values = value.split( ";" );
for ( int j = 0; j < values.size(); j++ )
{
QStringList args = values[j].split( "=" );
QVariant value;
if ( args.size() == 1 || ( args.size() == 2 && args[0] == args[1] ) )
{
QgsDebugMsg( QString( "idx:%1 key:%2 value:%2" ).arg( idx ).arg( args[0] ) );
value = args[0];
}
else if ( args.size() == 2 )
{
QgsDebugMsg( QString( "idx:%1 key:%2 value:%3" ).arg( idx ).arg( args[0] ).arg( args[1] ) );
value = args[1];
}
if ( value.canConvert( field.type() ) )
{
map.insert( args[0], value );
}
}
}
}
else if ( editType == QgsVectorLayer::EditRange ||
editType == QgsVectorLayer::SliderRange )
{
QStringList values = value.split( ";" );
if ( values.size() == 3 )
{
QVariant min = values[0];
QVariant max = values[1];
QVariant step = values[2];
if ( min.canConvert( field.type() ) &&
max.canConvert( field.type() ) &&
step.canConvert( field.type() ) )
{
min.convert( field.type() );
max.convert( field.type() );
step.convert( field.type() );
layer->range( idx ) = QgsVectorLayer::RangeData( min, max, step );
//.........这里部分代码省略.........
示例12: oper
//-----------------------------------------------------------------------------
void DatPanel::oper()
{
QLineEdit *f1;
QPushButton *b;
QDialog *d = new QDialog(this);
d->setWindowTitle(tr("UDAV - change data"));
QVBoxLayout *v = new QVBoxLayout(d);
QComboBox *c = new QComboBox(d); v->addWidget(c);
c->addItem(tr("Fill data by formula"));
c->addItem(tr("Transpose data with new dimensions"));
c->addItem(tr("Smooth data along direction(s)"));
c->addItem(tr("Summarize data along direction(s)"));
c->addItem(tr("Integrate data along direction(s)"));
c->addItem(tr("Differentiate data along direction(s)"));
c->addItem(tr("Laplace transform along direction(s)"));
c->addItem(tr("Swap data along direction(s)"));
c->addItem(tr("Mirror data along direction(s)"));
c->addItem(tr("Sin-Fourier transform along direction(s)"));
c->addItem(tr("Cos-Fourier transform along direction(s)"));
c->addItem(tr("Hankel transform along direction(s)"));
c->addItem(tr("Sew data along direction(s)"));
c->addItem(tr("Find envelope along direction(s)"));
c->setCurrentIndex(0);
f1 = new QLineEdit("z",d); v->addWidget(f1);
QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1);
b = new QPushButton(tr("Cancel"), d); h->addWidget(b);
connect(b, SIGNAL(clicked()), d, SLOT(reject()));
b = new QPushButton(tr("OK"), d); h->addWidget(b);
connect(b, SIGNAL(clicked()), d, SLOT(accept()));
b->setDefault(true);
// now execute dialog and get values
bool res = d->exec();
QString val = f1->text(), mgl;
int k = c->currentIndex();
QString self = QString::fromWCharArray(var->s.c_str());
if(res)
{
if(k<0)
{
QMessageBox::warning(d, tr("UDAV - make new data"),
tr("No action is selected. Do nothing."));
return;
}
switch(k)
{
case 0: mgl = "modify "+self+" '"+val+"'"; break;
case 1: mgl = "transpose "+self+" '"+val+"'"; break;
case 2: mgl = "smooth "+self+" '"+val+"'"; break;
case 3: mgl = "cumsum "+self+" '"+val+"'"; break;
case 4: mgl = "integrate "+self+" '"+val+"'"; break;
case 5: mgl = "diff "+self+" '"+val+"'"; break;
case 6: mgl = "diff2 "+self+" '"+val+"'"; break;
case 7: mgl = "swap "+self+" '"+val+"'"; break;
case 8: mgl = "mirror "+self+" '"+val+"'"; break;
case 9: mgl = "sinfft "+self+" '"+val+"'"; break;
case 10: mgl = "cosfft "+self+" '"+val+"'"; break;
case 11: mgl = "hankel "+self+" '"+val+"'"; break;
case 12: mgl = "sew "+self+" '"+val+"'"; break;
case 13: mgl = "envelop "+self+" '"+val+"'"; break;
}
}
if(!mgl.isEmpty())
{
mglGraph gr;
parser.Execute(&gr,mgl.toLocal8Bit().constData());
opers += mgl+"\n";
updateDataItems();
}
}
示例13: setModelData
void qtractorMidiEventItemDelegate::setModelData ( QWidget *pEditor,
QAbstractItemModel *pModel, const QModelIndex& index ) const
{
const qtractorMidiEventListModel *pListModel
= static_cast<const qtractorMidiEventListModel *> (pModel);
qtractorMidiEvent *pEvent = pListModel->eventOfIndex(index);
if (pEvent == NULL)
return;
qtractorMidiEditor *pMidiEditor = pListModel->editor();
if (pMidiEditor == NULL)
return;
#ifdef CONFIG_DEBUG
qDebug("qtractorMidiEventItemDelegate::setModelData(%p, %p, %d, %d)",
pEditor, pListModel, index.row(), index.column());
#endif
qtractorTimeScale *pTimeScale = pMidiEditor->timeScale();
qtractorMidiEditCommand *pEditCommand
= new qtractorMidiEditCommand(pMidiEditor->midiClip(),
tr("edit %1").arg(pListModel->headerData(
index.column(), Qt::Horizontal, Qt::DisplayRole)
.toString().toLower()));
switch (index.column()) {
case 0: // Time.
{
qtractorTimeSpinBox *pTimeSpinBox
= qobject_cast<qtractorTimeSpinBox *> (pEditor);
if (pTimeSpinBox) {
unsigned long iTime
= pTimeScale->tickFromFrame(pTimeSpinBox->valueFromText());
if (iTime > pMidiEditor->timeOffset())
iTime -= pMidiEditor->timeOffset();
else
iTime = 0;
unsigned long iDuration = 0;
if (pEvent->type() == qtractorMidiEvent::NOTEON)
iDuration = pEvent->duration();
pEditCommand->resizeEventTime(pEvent, iTime, iDuration);
}
break;
}
case 2: // Name.
{
QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
if (pComboBox) {
const int iNote = pComboBox->currentIndex();
const unsigned long iTime = pEvent->time();
pEditCommand->moveEvent(pEvent, iNote, iTime);
}
break;
}
case 3: // Value.
{
QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor);
if (pSpinBox) {
const int iValue = pSpinBox->value();
pEditCommand->resizeEventValue(pEvent, iValue);
}
break;
}
case 4: // Duration/Data.
{
qtractorTimeSpinBox *pTimeSpinBox
= qobject_cast<qtractorTimeSpinBox *> (pEditor);
if (pTimeSpinBox) {
const unsigned long iTime = pEvent->time();
const unsigned long iDuration
= pTimeScale->tickFromFrame(pTimeSpinBox->value());
pEditCommand->resizeEventTime(pEvent, iTime, iDuration);
}
break;
}
default:
break;
}
// Do it.
pMidiEditor->commands()->exec(pEditCommand);
}
示例14: drv_combobox
int drv_combobox(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
handle_head* head = (handle_head*)a0;
QComboBox *self = (QComboBox*)head->native;
switch (drvid) {
case COMBOBOX_INIT: {
drvNewObj(a0,new QComboBox);
break;
}
case COMBOBOX_COUNT: {
drvSetInt(a1,self->count());
break;
}
case COMBOBOX_SETCURRENTINDEX: {
self->setCurrentIndex(drvGetInt(a1));
break;
}
case COMBOBOX_CURRENTINDEX: {
drvSetInt(a1,self->currentIndex());
break;
}
case COMBOBOX_CURRENTTEXT: {
drvSetString(a1,self->currentText());
break;
}
case COMBOBOX_SETEDITABLE: {
self->setEditable(drvGetBool(a1));
break;
}
case COMBOBOX_ISEDITABLE: {
drvSetBool(a1,self->isEditable());
break;
}
case COMBOBOX_SETMAXCOUNT: {
self->setMaxCount(drvGetInt(a1));
break;
}
case COMBOBOX_MAXCOUNT: {
drvSetInt(a1,self->maxCount());
break;
}
case COMBOBOX_SETMAXVISIBLEITEMS: {
self->setMaxVisibleItems(drvGetInt(a1));
break;
}
case COMBOBOX_MAXVISIBLEITEMS: {
drvSetInt(a1,self->maxVisibleItems());
break;
}
case COMBOBOX_SETMINIMUMCONTENTSLENGTH: {
self->setMinimumContentsLength(drvGetInt(a1));
break;
}
case COMBOBOX_MINIMUNCONTENTSLENGHT: {
drvSetInt(a1,self->minimumContentsLength());
break;
}
case COMBOBOX_ADDITEM: {
self->addItem(drvGetString(a1));
break;
}
case COMBOBOX_INSERTITEM: {
self->insertItem(drvGetInt(a1),drvGetString(a2));
break;
}
case COMBOBOX_REMOVEITEM: {
self->removeItem(drvGetInt(a1));
break;
}
case COMBOBOX_ITEMTEXT: {
drvSetString(a2,self->itemText(drvGetInt(a1)));
break;
}
case COMBOBOX_ONCURRENTINDEXCHANGED: {
QObject::connect(self,SIGNAL(currentIndexChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
break;
}
default:
return 0;
}
return 1;
}
示例15: GenHTMLForm
//.........这里部分代码省略.........
ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
"<div class=\"row\">"
"<div class=\"prop\"><p>%1:</p></div>"
"<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
"<div class=\"submit\"><p> %7</p></div>"
"<div class=\"tooltip\"><p> %8</p></div>"
"</div></form>\n")
.arg(desc)
.arg(short_d)
.arg(item->value())
.arg(item->minimum())
.arg(item->maximum())
.arg(item->singleStep())
.arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />")
.arg(item->toolTip());
}
else if(objTypeName == "QDoubleSpinBox") {
QDoubleSpinBox *item = (QDoubleSpinBox *) obj;
ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
"<div class=\"row\">"
"<div class=\"prop\"><p>%1:</p></div>"
"<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
"<div class=\"submit\"><p> %7</p></div>"
"<div class=\"tooltip\"><p> %8</p></div>"
"</div></form>\n")
.arg(desc)
.arg(short_d)
.arg(item->value())
.arg(item->minimum())
.arg(item->maximum())
.arg(item->singleStep())
.arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />")
.arg(item->toolTip());
}
else if(objTypeName == "QComboBox") {
QComboBox *item = (QComboBox *) obj;
ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
"<div class=\"row\">"
"<div class=\"prop\"><p>%1:</p></div>"
"<div class=\"val\"><p>\n<select name=\"%2\" style=\"max-width:170px;\">\n").arg(desc).arg(short_d);
int current = item->currentIndex();
for (int i = 0; i < item->count(); i++) {
ret.append(QString("<option value=\"%1\" %2>%3</option>\n").arg(i).arg(i==current ? "selected" : "").arg(item->itemText(i)));
}
ret.append(QString("</select>\n</p></div>"
"<div class=\"submit\"><p> %1</p></div>"
"<div class=\"tooltip\"><p> %2</p></div>"
"</div></form>\n")
.arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />")
.arg(item->toolTip()));
}
else if(objTypeName == "QRadioButton") {
QRadioButton *item = (QRadioButton *) obj;
QString rb_vals;
if(item->objectName() == "radioButton_rds_music") {
rb_vals = QString("<input type=\"radio\" name=\"%1\" value=\"true\" %2/> Music <input type=\"radio\" name=\"%1\" value=\"false\" %3/> Speech")
.arg(short_d).arg(item->isChecked() ? "checked" : "").arg(item->isChecked() ? "" : "checked");
}
ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
"<div class=\"row\">"
"<div class=\"prop\"><p>%1:</p></div>"
"<div class=\"val\"><p>%3</p></div>"
"<div class=\"submit\"><p> %4</p></div>"
"<div class=\"tooltip\"><p> %5</p></div>"
"</div></form>\n")
.arg(desc)
.arg(short_d)
.arg(rb_vals)
.arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />")
.arg(item->toolTip());
}
else if(objTypeName == "QPushButton") {
QPushButton *item = (QPushButton *) obj;
ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
"<div class=\"row\">"
"<div class=\"prop\"><p>%1:</p></div>"
"<div class=\"val\"><p>%3</p></div>"
"<div class=\"submit\"><p> %4</p></div>"
"<div class=\"tooltip\"><p> %5</p></div>"
"</div></form>\n")
.arg(desc)
.arg(short_d)
.arg("action")
.arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />")
.arg(item->toolTip());
}
else {
qDebug() << "unimplemented obj_type: " << objTypeName;
}
return ret.toUtf8();
};