本文整理汇总了C++中QComboBox::currentText方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::currentText方法的具体用法?C++ QComboBox::currentText怎么用?C++ QComboBox::currentText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::currentText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateWidgetValue
void GPConfigDlg::updateWidgetValue(CameraWidget* widget)
{
CameraWidgetType widget_type;
gp_widget_get_type(widget, &widget_type);
switch (widget_type)
{
case GP_WIDGET_WINDOW:
// nothing to do
break;
case GP_WIDGET_SECTION:
// nothing to do
break;
case GP_WIDGET_TEXT:
{
QLineEdit* lineEdit = static_cast<QLineEdit*>(d->wmap[widget]);
gp_widget_set_value(widget, (void*)lineEdit->text().toLocal8Bit().data());
break;
}
case GP_WIDGET_RANGE:
{
QSlider* slider = static_cast<QSlider*>(d->wmap[widget]);
float value_float = slider->value();
gp_widget_set_value(widget, (void*)&value_float);
break;
}
case GP_WIDGET_TOGGLE:
{
QCheckBox* checkBox = static_cast<QCheckBox*>(d->wmap[widget]);
int value_int = checkBox->isChecked() ? 1 : 0;
gp_widget_set_value(widget, (void*)&value_int);
break;
}
case GP_WIDGET_RADIO:
{
Q3ButtonGroup* buttonGroup = static_cast<Q3VButtonGroup*>(d->wmap[widget]);
gp_widget_set_value(widget, (void*)buttonGroup->selected()->text().toLocal8Bit().data());
break;
}
case GP_WIDGET_MENU:
{
QComboBox* comboBox = static_cast<QComboBox*>(d->wmap[widget]);
gp_widget_set_value(widget, (void*)comboBox->currentText().toLocal8Bit().data());
break;
}
case GP_WIDGET_BUTTON:
// nothing to do
break;
case GP_WIDGET_DATE:
{
// not implemented
break;
}
}
// Copy child widget values
for (int i = 0; i < gp_widget_count_children(widget); ++i)
{
CameraWidget* widget_child;
gp_widget_get_child(widget, i, &widget_child);
updateWidgetValue(widget_child);
}
}
示例2: setModelData
void ComboBoxDelegateModulation::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
model->setData(index, comboBox->currentText(), Qt::EditRole);
}
示例3: changeID
void MocapPlugin::changeID(int index) {
QComboBox *cameraIDs = this->findChild<QComboBox *>("cameraIDs");
currentID = make_pair(index, cameraIDs->currentText().toInt());
}
示例4: buttonContextMenu
//.........这里部分代码省略.........
layout.addWidget(&command, row++, 1, 1, 2); // Spawn over two colums...
// layout.setColumnStretch(2, 2); // ...and take more space
label = new QLabel(tr("Symbol Type"));
label->setAlignment(Qt::AlignRight);
layout.addWidget(label, row, 0);
// QLineEdit symbolType(mSymbolTypes.at(id));
QComboBox symbolType;
symbolType.setToolTip(tr("Witch type has to be [Symbol]. When empty is called once with any symbol\n"
"(You should not use [Symbol] in this case at the command)"));
SymbolTypeTuple* st = mFilu->getSymbolTypes(Filu::eAllTypes);
if(st)
{
while(st->next()) symbolType.addItem(st->caption());
}
symbolType.addItem("");
symbolType.setCurrentIndex(symbolType.findText(mSymbolTypes.at(id)));
layout.addWidget(&symbolType, row, 1);
QCheckBox allMarkets(tr("All Markets"));
allMarkets.setToolTip(tr("Call multiple times with all markets by 'Symbol Type'"));
allMarkets.setChecked(mMultis.at(id));
layout.addWidget(&allMarkets, row++, 2);
// Add an empty row to take unused space
layout.addWidget(new QWidget, row, 1);
layout.setRowStretch(row++, 2);
// Build the button line
QDialogButtonBox dlgBtns(QDialogButtonBox::Save | QDialogButtonBox::Discard);
QPushButton* db = dlgBtns.button(QDialogButtonBox::Discard);
dlgBtns.addButton(db, QDialogButtonBox::RejectRole);
connect(&dlgBtns, SIGNAL(accepted()), &dialog, SLOT(accept()));
connect(&dlgBtns, SIGNAL(rejected()), &dialog, SLOT(reject()));
DialogButton* remove = new DialogButton(tr("&Remove"), -1);
remove->setToolTip(tr("Remove button"));
dlgBtns.addButton(remove, QDialogButtonBox::ActionRole);
connect(remove, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));
DialogButton* add = new DialogButton(tr("&Add"), 2);
add->setToolTip(tr("Copy to new button"));
dlgBtns.addButton(add, QDialogButtonBox::ActionRole);
connect(add, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));
layout.addWidget(&dlgBtns, row, 1, 1, 2);
dialog.setWindowTitle(tr("LaunchPad - Edit button '%1'").arg(btn->text()));
dialog.setMinimumWidth(350);
switch (dialog.exec())
{
case 0: // Discard
return;
break;
case -1: // Remove
{
int ret = QMessageBox::warning(&dialog
, tr("LaunchPad - Last chance to keep your data")
, tr("Are you sure to delete button <b>'%1'</b> with all your work<b>?</b>")
.arg(btn->text())
, QMessageBox::Yes | QMessageBox::No
, QMessageBox::No);
if(ret == QMessageBox::No) return;
deleteButton(btn);
mCommands.removeAt(id);
mSymbolTypes.removeAt(id);
mMultis.removeAt(id);
break;
}
case 1: // Save
setButtonName(btn, name.text());
btn->setToolTip(tip.text());
mCommands[id] = command.text();
//mCommands[id] = command.toPlainText();
// mSymbolTypes[id] = symbolType.text();
mSymbolTypes[id] = symbolType.currentText();
mMultis[id] = allMarkets.isChecked();
break;
case 2: // Add
btn = newButton(name.text());
btn->setToolTip(tip.text());
mCommands.append(command.text());
//mCommands.append(command.toPlainText());
// mSymbolTypes.append(symbolType.text());
mSymbolTypes.append(symbolType.currentText());
mMultis.append(allMarkets.isChecked());
mButtons.setId(btn, mCommands.size() - 1);
break;
}
saveSettings();
}
示例5: setModelData
void ComboBoxDelegate::setModelData (QWidget * editor, QAbstractItemModel *model, QModelIndex const & index) const
{
QComboBox * cbx = static_cast<QComboBox *>(editor);
QString value = cbx->currentText();
model->setData(index, value, Qt::EditRole);
}
示例6: configFromNextWidget
/**
@copydoc Configurable::configFromWidget
*/
void Configurable::configFromNextWidget(QObject* cur,ConfigParamList& paramList){
//parametres de configuration
const QObjectList& list = cur->children();
for(int i=0;i<list.size();i++)
{
QObject* child = list.at(i);
if(!child->objectName().isEmpty() && child->isWidgetType())
{
QString value;
// QLineEdit ?
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(child);
if(lineEdit)
value = lineEdit->text();
// QComboBox ?
QComboBox *comboBox = qobject_cast<QComboBox *>(child);
if(comboBox)
value = comboBox->currentText();
// QSpinBox ?
QSpinBox *spinBox = qobject_cast<QSpinBox *>(child);
if(spinBox)
value = spinBox->text();
// QDoubleSpinBox ?
QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox *>(child);
if(doubleSpinBox)
value = doubleSpinBox->text();
// QTextEdit ?
QTextEdit *textEdit = qobject_cast<QTextEdit *>(child);
if(textEdit)
value = textEdit->toPlainText();
// QPlainTextEdit ?
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(child);
if(plainTextEdit)
value = plainTextEdit->toPlainText();
// QTimeEdit ?
QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(child);
if(timeEdit)
value = timeEdit->text();
// QDateTimeEdit ?
QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit *>(child);
if(dateTimeEdit)
value = timeEdit->text();
// QDateEdit ?
QDateEdit *dateEdit = qobject_cast<QDateEdit *>(child);
if(dateEdit)
value = dateEdit->text();
// QDial ?
QDial *dial = qobject_cast<QDial *>(child);
if(dial)
value = QString::number(dial->value());
// QSlider ?
QSlider *slider = qobject_cast<QSlider *>(child);
if(slider)
value = QString::number(slider->value());
//sauvegarde la valeur
if(!value.isNull()){
/*#ifdef _DEBUG
QPRINT("loadConfig >> "+child->objectName()+"="+value);
#endif*/
if(paramList.find(child->objectName()) != paramList.end())
paramList[child->objectName()]->setValue(value);
else
paramList[child->objectName()] = new ConfigParam(value,"");
}
}
Configurable::configFromNextWidget(child,paramList);
}
}
示例7: OnSave
void EditorDialog::OnSave()
{
// Store all edits.
if (m_feature.IsNameEditable())
{
StringUtf8Multilang names;
for (int8_t langCode = StringUtf8Multilang::kDefaultCode;
langCode < StringUtf8Multilang::kMaxSupportedLanguages; ++langCode)
{
QLineEdit * le = findChild<QLineEdit *>(StringUtf8Multilang::GetLangByCode(langCode));
if (!le)
continue;
string const name = le->text().toStdString();
if (!name.empty())
names.AddString(langCode, name);
}
m_feature.SetName(names);
}
if (m_feature.IsAddressEditable())
{
m_feature.SetHouseNumber(findChild<QLineEdit *>(kHouseNumberObjectName)->text().toStdString());
QString const editedStreet = findChild<QComboBox *>(kStreetObjectName)->currentText();
QStringList const names = editedStreet.split(" / ", QString::SkipEmptyParts);
QString const localized = names.size() > 1 ? names.at(1) : QString();
if (!names.empty())
m_feature.SetStreet({names.at(0).toStdString(), localized.toStdString()});
else
m_feature.SetStreet({});
m_feature.SetPostcode(findChild<QLineEdit *>(kPostcodeObjectName)->text().toStdString());
}
for (osm::Props const prop : m_feature.GetEditableProperties())
{
if (prop == osm::Props::Internet)
{
QComboBox * cmb = findChild<QComboBox *>(kInternetObjectName);
string const str = cmb->currentText().toStdString();
osm::Internet v = osm::Internet::Unknown;
if (str == DebugPrint(osm::Internet::Wlan))
v = osm::Internet::Wlan;
else if (str == DebugPrint(osm::Internet::Wired))
v = osm::Internet::Wired;
else if (str == DebugPrint(osm::Internet::No))
v = osm::Internet::No;
else if (str == DebugPrint(osm::Internet::Yes))
v = osm::Internet::Yes;
m_feature.SetInternet(v);
continue;
}
QLineEdit * editor = findChild<QLineEdit *>(QString::fromStdString(DebugPrint(prop)));
if (!editor)
continue;
string const v = editor->text().toStdString();
switch (prop)
{
case osm::Props::Phone: m_feature.SetPhone(v); break;
case osm::Props::Fax: m_feature.SetFax(v); break;
case osm::Props::Email: m_feature.SetEmail(v); break;
case osm::Props::Website: m_feature.SetWebsite(v); break;
case osm::Props::Internet: ASSERT(false, ("Is handled separately above."));
case osm::Props::Cuisine:
{
vector<string> cuisines;
strings::Tokenize(v, ";", MakeBackInsertFunctor(cuisines));
m_feature.SetCuisines(cuisines);
}
break;
case osm::Props::OpeningHours: m_feature.SetOpeningHours(v); break;
case osm::Props::Stars:
{
int num;
if (strings::to_int(v, num))
m_feature.SetStars(num);
}
break;
case osm::Props::Operator: m_feature.SetOperator(v); break;
case osm::Props::Elevation:
{
double ele;
if (strings::to_double(v, ele))
m_feature.SetElevation(ele);
}
break;
case osm::Props::Wikipedia: m_feature.SetWikipedia(v); break;
case osm::Props::Flats: m_feature.SetFlats(v); break;
case osm::Props::BuildingLevels: m_feature.SetBuildingLevels(v); break;
}
}
accept();
}
示例8: filterChanged
void QgsRelationReferenceWidget::filterChanged()
{
QVariant nullValue = QgsApplication::nullRepresentation();
QMap<QString, QString> filters;
QgsAttributeList attrs;
QComboBox *scb = qobject_cast<QComboBox *>( sender() );
Q_ASSERT( scb );
QgsFeature f;
QgsFeatureIds featureIds;
QString filterExpression;
// comboboxes have to be disabled before building filters
if ( mChainFilters )
disableChainedComboBoxes( scb );
// build filters
const auto constMFilterComboBoxes = mFilterComboBoxes;
for ( QComboBox *cb : constMFilterComboBoxes )
{
if ( cb->currentIndex() != 0 )
{
const QString fieldName = cb->property( "Field" ).toString();
if ( cb->currentText() == nullValue.toString() )
{
filters[fieldName] = QStringLiteral( "\"%1\" IS NULL" ).arg( fieldName );
}
else
{
filters[fieldName] = QgsExpression::createFieldEqualityExpression( fieldName, cb->currentText() );
}
attrs << mReferencedLayer->fields().lookupField( fieldName );
}
}
if ( mChainFilters )
{
QComboBox *ccb = nullptr;
const auto constMFilterComboBoxes = mFilterComboBoxes;
for ( QComboBox *cb : constMFilterComboBoxes )
{
if ( !ccb )
{
if ( cb == scb )
ccb = cb;
continue;
}
if ( ccb->currentIndex() != 0 )
{
const QString fieldName = cb->property( "Field" ).toString();
cb->blockSignals( true );
cb->clear();
cb->addItem( cb->property( "FieldAlias" ).toString() );
// ccb = scb
// cb = scb + 1
QStringList texts;
const auto txts { mFilterCache[ccb->property( "Field" ).toString()][ccb->currentText()] };
for ( const QString &txt : txts )
{
QMap<QString, QString> filtersAttrs = filters;
filtersAttrs[fieldName] = QgsExpression::createFieldEqualityExpression( fieldName, txt );
QString expression = filtersAttrs.values().join( QStringLiteral( " AND " ) );
QgsAttributeList subset = attrs;
subset << mReferencedLayer->fields().lookupField( fieldName );
QgsFeatureIterator it( mReferencedLayer->getFeatures( QgsFeatureRequest().setFilterExpression( expression ).setSubsetOfAttributes( subset ) ) );
bool found = false;
while ( it.nextFeature( f ) )
{
if ( !featureIds.contains( f.id() ) )
featureIds << f.id();
found = true;
}
// item is only provided if at least 1 feature exists
if ( found )
texts << txt;
}
texts.sort();
cb->addItems( texts );
cb->setEnabled( true );
cb->blockSignals( false );
ccb = cb;
}
}
}
//.........这里部分代码省略.........
示例9: setModelData
void BrainTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
const BrainTreeModel* pBrainTreeModel = static_cast<const BrainTreeModel*>(index.model());
const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pBrainTreeModel->itemFromIndex(index));
switch(pAbstractItem->type()) {
case BrainTreeModelItemTypes::SurfaceColorGyri: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, BrainTreeItemRoles::SurfaceColorGyri);
model->setData(index, data, Qt::DecorationRole);
return;
}
case BrainTreeModelItemTypes::SurfaceColorSulci: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, BrainTreeItemRoles::SurfaceColorSulci);
model->setData(index, data, Qt::DecorationRole);
return;
}
case BrainTreeModelItemTypes::SurfaceColorInfoOrigin: {
QComboBox* pColorDialog = static_cast<QComboBox*>(editor);
QVariant data;
data.setValue(pColorDialog->currentText());
model->setData(index, data, BrainTreeItemRoles::SurfaceColorInfoOrigin);
model->setData(index, data, Qt::DisplayRole);
return;
}
case BrainTreeModelItemTypes::RTDataColormapType: {
QComboBox* pColorDialog = static_cast<QComboBox*>(editor);
QVariant data;
data.setValue(pColorDialog->currentText());
model->setData(index, data, BrainTreeItemRoles::RTDataColormapType);
model->setData(index, data, Qt::DisplayRole);
return;
}
case BrainTreeModelItemTypes::RTDataNormalizationValue: {
QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
QVariant data;
data.setValue(pDoubleSpinBox->value());
model->setData(index, data, BrainTreeItemRoles::RTDataNormalizationValue);
model->setData(index, data, Qt::DisplayRole);
break;
}
case BrainTreeModelItemTypes::RTDataTimeInterval: {
QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
QVariant data;
data.setValue(pSpinBox->value());
model->setData(index, data, BrainTreeItemRoles::RTDataTimeInterval);
model->setData(index, data, Qt::DisplayRole);
break;
}
}
QItemDelegate::setModelData(editor, model, index);
}
示例10: 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;
}
示例11: tr
void synthv1widget_controls_item_delegate::setModelData ( QWidget *pEditor,
QAbstractItemModel *pModel, const QModelIndex& index ) const
{
#ifdef CONFIG_DEBUG_0
qDebug("synthv1widget_controls_item_delegate::setModelData(%p, %d, %d)",
pEditor, index.row(), index.column());
#endif
switch (index.column()) {
case 0: // Channel.
{
QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor);
if (pSpinBox) {
const int iChannel = pSpinBox->value();
const QString& sText
= (iChannel > 0 ? QString::number(iChannel) : tr("Auto"));
pModel->setData(index, sText);
}
break;
}
case 1: // Type.
{
QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
if (pComboBox) {
const QString& sType = pComboBox->currentText();
pModel->setData(index, sType);
}
break;
}
case 2: // Parameter.
{
QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
if (pComboBox) {
const int iIndex = pComboBox->currentIndex();
QString sText;
int iParam;
if (iIndex >= 0) {
sText = pComboBox->itemText(iIndex);
iParam = pComboBox->itemData(iIndex).toInt();
} else {
sText = pComboBox->currentText();
iParam = sText.toInt();
}
pModel->setData(index, sText);
pModel->setData(index, iParam, Qt::UserRole);
}
break;
}
case 3: // Subject.
{
QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
if (pComboBox) {
const int iIndex = pComboBox->currentIndex();
pModel->setData(index,
synthv1_param::paramName(synthv1::ParamIndex(iIndex)));
pModel->setData(index, iIndex, Qt::UserRole);
}
break;
}
default:
break;
}
// Done.
}
示例12: callDialog
mass* massDialog::callDialog(modeler *md)
{
QList<QString> geoList = md->objects().keys();
QStringList geoStrList;
for (unsigned int i = 0; i < geoList.size(); i++){
geoStrList.push_back(geoList[i]);
}
QComboBox *CBBase = new QComboBox;
CBBase->addItems(geoStrList);
QLabel *LCBBase = new QLabel("Base geometry");
QLabel *LMass, *LIxx, *LIyy, *LIzz, *LIxy, *LIxz, *LIzy;
QLineEdit *LEMass, *LEIxx, *LEIyy, *LEIzz, *LEIxy, *LEIxz, *LEIzy;
LMass = new QLabel("Mass"); LEMass = new QLineEdit;
LIxx = new QLabel("Ixx"); LEIxx = new QLineEdit;
LIyy = new QLabel("Iyy"); LEIyy = new QLineEdit;
LIzz = new QLabel("Izz"); LEIzz = new QLineEdit;
LIxy = new QLabel("Ixy"); LEIxy = new QLineEdit;
LIxz = new QLabel("Ixz"); LEIxz = new QLineEdit;
LIzy = new QLabel("Izy"); LEIzy = new QLineEdit;
PBOk = new QPushButton("OK");
PBCancel = new QPushButton("Cancel");
connect(PBOk, SIGNAL(clicked()), this, SLOT(Click_ok()));
connect(PBCancel, SIGNAL(clicked()), this, SLOT(Click_cancel()));
QGridLayout *massLayout = new QGridLayout;
massLayout->addWidget(LCBBase, 0, 0);
massLayout->addWidget(CBBase, 0, 1, 1, 2);
massLayout->addWidget(LMass, 1, 0);
massLayout->addWidget(LEMass, 1, 1, 1, 2);
massLayout->addWidget(LIxx, 2, 0);
massLayout->addWidget(LEIxx, 2, 1, 1, 1);
massLayout->addWidget(LIxy, 3, 0);
massLayout->addWidget(LEIxy, 3, 1, 1, 1);
massLayout->addWidget(LIyy, 3, 2);
massLayout->addWidget(LEIyy, 3, 3, 1, 1);
massLayout->addWidget(LIxz, 4, 0);
massLayout->addWidget(LEIxz, 4, 1, 1, 1);
massLayout->addWidget(LIzy, 4, 2);
massLayout->addWidget(LEIzy, 4, 3, 1, 1);
massLayout->addWidget(LIzz, 4, 4);
massLayout->addWidget(LEIzz, 4, 5, 1, 1);
massLayout->addWidget(PBOk, 5, 4);
massLayout->addWidget(PBCancel, 5, 5);
this->setLayout(massLayout);
this->exec();
mass* m = NULL;
if (isDialogOk)
{
m = md->makeMass(CBBase->currentText());
m->setMass(LEMass->text().toFloat());
VEC3D syminer; //inertia
syminer.x = LEIxy->text().toFloat();
syminer.y = LEIxz->text().toFloat();
syminer.z = LEIzy->text().toFloat();
m->setSymIner(syminer);
VEC3D prininer;
prininer.x = LEIxx->text().toFloat();
prininer.y = LEIyy->text().toFloat();
prininer.z = LEIzz->text().toFloat();
m->setPrinIner(prininer);
m->setInertia();//m->define();
}
return m;
}
示例13: 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() );
}
//.........这里部分代码省略.........
示例14: main
//.........这里部分代码省略.........
stack->addWidget(test);
stack->setCurrentIndex(1);
/* toggle test or error */
QPushButton *hash = new QPushButton(QIcon(":/icon"), "");
hash->setCheckable(true);
hash->setChecked(true);
hash->setToolTip(Window::tr("Compare hashes"));
QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex);
/* store method */
QSettings settings("H4KvT", "H4KvT");
/* more methods */
bool more;
try {
settings.setValue("MoreHashingMethods", more = moreOrLess());
} catch (...) {
more = settings.value("MoreHashingMethods", false).toBool();
}
/* hashing method */
QComboBox *meth = new QComboBox;
meth->addItem("md5");
meth->addItem("sha1");
if (more) meth->addItem("sha224");
meth->addItem("sha256");
if (more) meth->addItem("sha384");
meth->addItem("sha512");
meth->setToolTip(Window::tr("Hashing method"));
meth->setCurrentText(settings.value("HashingMethod", "md5").toString());
QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled);
QObject::connect(meth, &QComboBox::currentTextChanged,
[&](const QString &text) { settings.setValue("HashingMethod", text); });
/* toolbar */
QHBoxLayout *pane = new QHBoxLayout;
pane->addWidget(hash, 0, Qt::AlignLeft);
pane->addWidget(stack);
pane->addWidget(meth, 0, Qt::AlignRight);
/* main layout */
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(text);
layout->addLayout(pane);
/* the window */
window.centralWidget()->setLayout(layout);
window.show();
/* future hashing */
QFutureWatcher<Vals> zu;
QObject::connect(&zu, &QFutureWatcher<Vals>::finished,
[&]() {
Vals valsi = zu.future().result();
window.idle(true);
if (valsi.path == "") {
error->setText(QString::fromStdString(valsi.name));
hash->setChecked(false);
} else {
error->clear();
vals += valsi;
test->textChanged(test->text());
}
});
示例15: getUserCommandParams
bool WulforUtil::getUserCommandParams(const UserCommand& uc, StringMap& params) {
StringList names;
string::size_type i = 0, j = 0;
const string cmd_str = uc.getCommand();
while((i = cmd_str.find("%[line:", i)) != string::npos) {
if ((j = cmd_str.find("]", (i += 7))) == string::npos)
break;
names.push_back(cmd_str.substr(i, j - i));
i = j + 1;
}
if (names.empty())
return true;
QDialog dlg(MainWindow::getInstance());
dlg.setWindowTitle(_q(uc.getDisplayName().back()));
QVBoxLayout *vlayout = new QVBoxLayout(&dlg);
std::vector<std::function<void ()> > valueFs;
for (const auto &name : names) {
QString caption = _q(name);
if (uc.adc()) {
caption.replace("\\\\", "\\");
caption.replace("\\s", " ");
}
int combo_sel = -1;
QString combo_caption = caption;
combo_caption.replace("//", "\t");
QStringList combo_values = combo_caption.split("/");
if (combo_values.size() > 2) {
QString tmp = combo_values.takeFirst();
bool isNumber = false;
combo_sel = combo_values.takeFirst().toInt(&isNumber);
if (!isNumber || combo_sel >= combo_values.size())
combo_sel = -1;
else
caption = tmp;
}
QGroupBox *box = new QGroupBox(caption, &dlg);
QHBoxLayout *hlayout = new QHBoxLayout(box);
if (combo_sel >= 0) {
for (auto &val : combo_values)
val.replace("\t", "/");
QComboBox *combo = new QComboBox(box);
hlayout->addWidget(combo);
combo->addItems(combo_values);
combo->setEditable(true);
combo->setCurrentIndex(combo_sel);
combo->lineEdit()->setReadOnly(true);
valueFs.push_back([combo, name, ¶ms] {
params["line:" + name] = combo->currentText().toStdString();
});
} else {
QLineEdit *line = new QLineEdit(box);
hlayout->addWidget(line);
valueFs.push_back([line, name, ¶ms] {
params["line:" + name] = line->text().toStdString();
});
}
vlayout->addWidget(box);
}
QDialogButtonBox *buttonBox = new QDialogButtonBox(&dlg);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
vlayout->addWidget(buttonBox);
dlg.setFixedHeight(vlayout->sizeHint().height());
connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
if (dlg.exec() != QDialog::Accepted)
return false;
for (const auto &fs : valueFs)
fs();
return true;
}