当前位置: 首页>>代码示例>>C++>>正文


C++ QComboBox::setCurrentText方法代码示例

本文整理汇总了C++中QComboBox::setCurrentText方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setCurrentText方法的具体用法?C++ QComboBox::setCurrentText怎么用?C++ QComboBox::setCurrentText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QComboBox的用法示例。


在下文中一共展示了QComboBox::setCurrentText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setEditorData

void BrainTreeDelegate::setEditorData(QWidget* editor, 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: {
            QColor color = index.model()->data(index, BrainTreeItemRoles::SurfaceColorGyri).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case BrainTreeModelItemTypes::SurfaceColorSulci: {
            QColor color = index.model()->data(index, BrainTreeItemRoles::SurfaceColorSulci).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case BrainTreeModelItemTypes::SurfaceColorInfoOrigin: {
            QString colorOrigin = index.model()->data(index, BrainTreeItemRoles::SurfaceColorInfoOrigin).toString();
            QComboBox* pComboBox = static_cast<QComboBox*>(editor);
            pComboBox->setCurrentText(colorOrigin);
            break;
        }

        case BrainTreeModelItemTypes::RTDataColormapType: {
            QString colormap = index.model()->data(index, BrainTreeItemRoles::RTDataColormapType).toString();
            QComboBox* pComboBox = static_cast<QComboBox*>(editor);
            pComboBox->setCurrentText(colormap);
            break;
        }

        case BrainTreeModelItemTypes::RTDataNormalizationValue: {
            double value = index.model()->data(index, BrainTreeItemRoles::RTDataNormalizationValue).toDouble();
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            pDoubleSpinBox->setValue(value);
            break;
        }

        case BrainTreeModelItemTypes::RTDataTimeInterval: {
            int value = index.model()->data(index, BrainTreeItemRoles::RTDataTimeInterval).toInt();
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
            pSpinBox->setValue(value);
            break;
        }
    }

    QItemDelegate::setEditorData(editor, index);
}
开发者ID:BulatSuleymanoff,项目名称:mne-cpp,代码行数:51,代码来源:braintreedelegate.cpp

示例2: setWidgetData

void table_widget_delegate::setWidgetData(const QModelIndex &index, QWidget *editor, const QVariant& data) const
{
	if (!editor){
		return;
	}

	column_data_ptr cd = _column_datas[index.column()];
	if (!cd){
		return;
	}

	switch (cd->type)
	{
	case WIDGET_CHECKBOX:
        {
            QCheckBox *widget = qobject_cast<QCheckBox*>(editor);
            if(widget){
                widget->setChecked(data.toBool());
            }
        }
		break;
	case  WIDGET_COMBOBOX:
		{
			QComboBox *widget = qobject_cast<QComboBox*>(editor);
			switch (cd->data.type())
			{
			case QVariant::StringList:
				widget->setCurrentText(data.toString());
				break;
			case QVariant::Map:
				{
					  QVariantMap map = cd->data.toMap();
					  QString text;
					  for (auto it = map.begin(); it != map.end(); ++it){
						  if (data == it.value()){
							  text = it.key();
						  }
					  }

					  widget->setCurrentText(text);
				}
				break;
			default:
				break;
			}
		}
	default:
		break;
	}
}
开发者ID:jadderbao,项目名称:http-post-test,代码行数:50,代码来源:table_widget_delegate.cpp

示例3: setEditorData

void EventDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    switch(index.column()) {
        case 0: {
            int value = index.model()->data(index, Qt::DisplayRole).toInt();
            QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
            spinBox->setValue(value);
            break;
        }

        case 1: {
            double value = index.model()->data(index, Qt::DisplayRole).toDouble();
            QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
            spinBox->setValue(value);
            break;
        }

        case 2: {
            int value = index.model()->data(index, Qt::DisplayRole).toInt();
            QComboBox *spinBox = static_cast<QComboBox*>(editor);
            spinBox->setCurrentText(QString().number(value));
            break;
        }
    }
}
开发者ID:JanaKiesel,项目名称:mne-cpp,代码行数:25,代码来源:eventdelegate.cpp

示例4: setEditorData

void UatDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    uat_field_t *field = indexToField(index);

    switch (field->mode) {
    case PT_TXTMOD_ENUM:
    {
        QComboBox *combobox = static_cast<QComboBox *>(editor);
        const QString &data = index.model()->data(index, Qt::EditRole).toString();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
        combobox->setCurrentText(data);
#else
        int new_index = combobox->findText(data);
        if (new_index >= 0) {
            combobox->setCurrentIndex(new_index);
        }
#endif

        break;
    }

    default:
        QStyledItemDelegate::setEditorData(editor, index);
    }
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:25,代码来源:uat_delegate.cpp

示例5: VisibilityDelegateSetup

void QuickEdit::VisibilityDelegateSetup()
{
    GenericDelegate* visibilityDelegate = new GenericDelegate(ui->tvEditor, false);
    visibilityDelegate->widgetCreator = [&](QWidget * parent)
    {
        QStringList visibilities = {"public" , "protected", "private", "package", "default"};
        QComboBox* box = new QComboBox(parent);
        QStringListModel* model = new QStringListModel;
        model->setStringList(visibilities);
        box->setModel(model);
        box->setEditable(false);
        return box;
    };
    visibilityDelegate->dataAccessor = [](QWidget * editor, const QModelIndex & index)
    {
        QString value = index.model()->data(index, Qt::EditRole).toString();
        QComboBox *box = static_cast<QComboBox*>(editor);
        box->setCurrentText(value);
    };
    visibilityDelegate->dataSetter = [](QWidget * editor,QAbstractItemModel* model, const QModelIndex &index)
    {
        QComboBox * box = static_cast<QComboBox*>(editor);
        QString value = box->currentText();
        model->setData(index, value, Qt::EditRole);
    };
    ui->tvEditor->setItemDelegateForColumn(columns.indexOf("visibility"), visibilityDelegate);
}
开发者ID:open-src,项目名称:douml,代码行数:27,代码来源:quickedit.cpp

示例6: DirectionDelegateSetup

void QuickEdit::DirectionDelegateSetup()
{
    GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false);

    delegate->widgetCreator = [](QWidget* parent)
    {
        QStringList visibilities;
        visibilities << "inout" << "in" << "out";
        QComboBox* box = new QComboBox(parent);
        QStringListModel* model = new QStringListModel;
        model->setStringList(visibilities);
        box->setModel(model);
        box->setEditable(false);
        return box;
    };
    
    delegate->dataAccessor = [](QWidget* editor, const QModelIndex& index)
    {
        QString value = index.model()->data(index, Qt::EditRole).toString();
        QComboBox* box = static_cast<QComboBox*>(editor);
        box->setCurrentText(value);
    };

    delegate->dataSetter = [](QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)
    {
        QComboBox* box = static_cast<QComboBox*>(editor);
        QString value = box->currentText();
        model->setData(index, value, Qt::EditRole);
    };

    ui->tvEditor->setItemDelegateForColumn(columns.indexOf("direction"), delegate);
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:32,代码来源:quickedit.cpp

示例7: setEditorData

void ComboBoxItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
	const QString value = index.model()->data(index, Qt::EditRole).toString();

	QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
	comboBox->setCurrentText(value);
}
开发者ID:Roger-Waters,项目名称:KITScenarist,代码行数:7,代码来源:ComboBoxItemDelegate.cpp

示例8: setEditorData

void ObjektDelegate::setEditorData ( QWidget *editor, const QModelIndex &index ) const
{

  QComboBox *box = static_cast<QComboBox*> (editor);
  box->setCurrentText(index.data().toString());

}
开发者ID:MrRisoni,项目名称:Gauss,代码行数:7,代码来源:objektdelegate.cpp

示例9: PrefixDelegateSetup

void QuickEdit::PrefixDelegateSetup()
{
    GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false);
    delegate->widgetCreator = [&](QWidget * parent)
    {
        QStringList list;
        list << " " << "const " << "volatile ";
        QCompleter *completer = new QCompleter(list, parent);
        completer->setCaseSensitivity(Qt::CaseSensitive);


        QComboBox* box = new QComboBox(parent);
        QStringListModel* model = new QStringListModel;
        model->setStringList(list);
        box->setModel(model);
        box->setEditable(true);
        box->setCompleter(completer);
        return box;
    };
    delegate->dataAccessor = [](QWidget * editor, const QModelIndex & index)
    {
        QString value = index.model()->data(index, Qt::EditRole).toString();
        QComboBox *box = static_cast<QComboBox*>(editor);
        box->setCurrentText(value);
    };
    delegate->dataSetter = [](QWidget * editor,QAbstractItemModel* model, const QModelIndex &index)
    {
        QComboBox * box = static_cast<QComboBox*>(editor);
        QString value = box->currentText();
        model->setData(index, value, Qt::EditRole);
    };
    ui->tvEditor->setItemDelegateForColumn(columns.indexOf("prefix"), delegate);
}
开发者ID:open-src,项目名称:douml,代码行数:33,代码来源:quickedit.cpp

示例10: displayProperties

void VCMatrixPresetSelection::displayProperties(RGBScript *script)
{
    if (script == NULL)
        return;

    int gridRowIdx = 0;

    QList<RGBScriptProperty> properties = script->properties();
    if (properties.count() > 0)
        m_propertiesGroup->show();
    else
        m_propertiesGroup->hide();

    foreach(RGBScriptProperty prop, properties)
    {
        switch(prop.m_type)
        {
            case RGBScriptProperty::List:
            {
                QLabel *propLabel = new QLabel(prop.m_displayName);
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
                QComboBox *propCombo = new QComboBox(this);
                propCombo->addItems(prop.m_listValues);
                propCombo->setProperty("pName", prop.m_name);
                QString pValue = script->property(prop.m_name);
                if (!pValue.isEmpty())
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
                    propCombo->setCurrentText(pValue);
#else
                    propCombo->setCurrentIndex(propCombo->findText(pValue));
#endif
                connect(propCombo, SIGNAL(currentIndexChanged(QString)),
                        this, SLOT(slotPropertyComboChanged(QString)));
                m_propertiesLayout->addWidget(propCombo, gridRowIdx, 1);
                gridRowIdx++;
            }
            break;
            case RGBScriptProperty::Range:
            {
                QLabel *propLabel = new QLabel(prop.m_displayName);
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
                QSpinBox *propSpin = new QSpinBox(this);
                propSpin->setRange(prop.m_rangeMinValue, prop.m_rangeMaxValue);
                propSpin->setProperty("pName", prop.m_name);
                QString pValue = script->property(prop.m_name);
                if (!pValue.isEmpty())
                    propSpin->setValue(pValue.toInt());
                connect(propSpin, SIGNAL(valueChanged(int)),
                        this, SLOT(slotPropertySpinChanged(int)));
                m_propertiesLayout->addWidget(propSpin, gridRowIdx, 1);
                gridRowIdx++;
            }
            break;
            default:
                qWarning() << "Type" << prop.m_type << "not handled yet";
            break;
        }
    }
}
开发者ID:Cingulingu,项目名称:qlcplus,代码行数:59,代码来源:vcmatrixpresetselection.cpp

示例11: setEditorData

void IntermodTraceDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
    QComboBox *combo = qobject_cast<QComboBox*>(editor);
    if (!combo) {
        QStyledItemDelegate::setEditorData(editor, index);
        return;
    }

    const QString text = index.data().toString();
    combo->setCurrentText(text);
}
开发者ID:Terrabits,项目名称:TwoToneSweep,代码行数:10,代码来源:IntermodTraceDelegate.cpp

示例12: setRow

void ConfigPrintDialog::setRow(QTableWidget *table, int row, QStringList values)
{
    qDebug() << "ConfigPrintDialog::setRow()";
    //Imposta i valori della QStringList values nella riga con indice row
    //della QTableWidget table.
    for (int col=0; col<table->columnCount(); col++) {
        if (col == DESCR || col == ALIGN) {
            QComboBox *cb = qobject_cast<QComboBox *>(table->cellWidget(row, col));
            cb->setCurrentText(values[col]);
        }
        else {
            QLineEdit *le = qobject_cast<QLineEdit *>(table->cellWidget(row, col));
            le->setText(values[col]);
        }
    }
}
开发者ID:kvsd,项目名称:Gestionale,代码行数:16,代码来源:configprintdialog.cpp

示例13: addProperty

void EditEventDialog::addProperty(const EventAttribute &attribute) {
    assert(mEvent.mData.count(attribute.mID) <= 1);
    QString defaultValue;
    if (mEvent.mData.count(attribute.mID) == 1) {
        defaultValue = mEvent.mData.find(attribute.mID).value();
    }
    QWidget *pDataWidget = NULL;
    QFormLayout *pLayout = NULL;
    switch (attribute.mLayoutType) {
    case LAYOUT_EMITTER:
        pLayout = dynamic_cast<QFormLayout*>(ui->emitterGroupBox->layout());
        break;
    case LAYOUT_EVENT:
        pLayout = dynamic_cast<QFormLayout*>(ui->eventGroupBox->layout());
        break;
    case LAYOUT_CHILD_DATA:
        pLayout = ui->childDataLayout;
        break;
    }
    if (attribute.mPropertyType == SELECT_TYPE) {
        QComboBox *pCB = new QComboBox(this);
        pCB->addItems(attribute.mAllowedValues);
        pCB->setCurrentText(defaultValue);

        QObject::connect(pCB, SIGNAL(currentIndexChanged(QString)), this, SLOT(onComboBoxValueChanged(QString)));
        mEditingEvent.mData[attribute.mID] = defaultValue;

        pDataWidget = pCB;
    }
    else if (attribute.mPropertyType == STRING_TYPE) {
        QLineEdit *pLineEdit = new QLineEdit(this);
        pLineEdit->setText(defaultValue);
        QObject::connect(pLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onLineEditValueChanged(QString)));

        pDataWidget = pLineEdit;
    }
    else if (attribute.mPropertyType == BOOL_TYPE) {
        QCheckBox *pCB = new QCheckBox(this);
        pCB->setChecked(defaultValue.toLower() == "true");
        pDataWidget = pCB;

        QObject::connect(pCB, SIGNAL(toggled(bool)), this, SLOT(onCheckBoxValueChanged(bool)));
    }
开发者ID:ChWick,项目名称:Mencus-Map-Editor,代码行数:43,代码来源:editeventdialog.cpp

示例14: addColumn

/**
 * Add elements to set additional column name and sort order
 */
void SortTableWorkspaceDialog::addColumn()
{
  m_form.lblColumnName->setText( "Column 1" );
  // create controls for setting new column
  auto newRow = m_sortColumns.size();
  assert( newRow <= m_columnNames.size() );
  QLabel *label = new QLabel( QString("Column %1").arg(newRow+1) );
  QComboBox *columnName = new QComboBox();
  columnName->addItems( m_columnNames );
  columnName->setToolTip( m_form.cbColumnName->toolTip() );
  connect( columnName, SIGNAL(currentIndexChanged(int)), this, SLOT(changedColumnName(int)) );
  QComboBox *ascending = new QComboBox();
  ascending->addItem("Ascending");
  ascending->addItem("Descending");
  ascending->setToolTip( m_form.cbAscending->toolTip() );
  // add them to the layout
  m_form.columnsLayout->addWidget(label,newRow,0);
  m_form.columnsLayout->addWidget(columnName,newRow,1);
  m_form.columnsLayout->addWidget(ascending,newRow,2);
  // correct the tab order
  QWidget::setTabOrder( m_form.columnsLayout->itemAtPosition( newRow - 1, 2 )->widget(), columnName );
  QWidget::setTabOrder( columnName, ascending );

  // suggest a name for the new column: one that hasn't been used in 
  // other sort columns
  QString newColumnName;
  foreach(QString name, m_columnNames)
  {
    if ( !m_sortColumns.contains(name) )
    {
      columnName->setCurrentText( name );
      break;
    }
  }
  // cache the column name
  m_sortColumns << columnName->currentText();
  // set the Add/Remove buttons into a correct state
  if ( m_sortColumns.size() == m_columnNames.size() )
  {
    m_form.btnAddColumn->setEnabled(false);
  }
  m_form.btnRemoveColumn->setEnabled(true);
}
开发者ID:dezed,项目名称:mantid,代码行数:46,代码来源:SortTableWorkspaceDialog.cpp

示例15: TypeDelegateSetup

void QuickEdit::TypeDelegateSetup()
{
    GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false);

    delegate->widgetCreator = [](QWidget* parent)
    {
        BrowserNodeList result;
        QStringList classes;
        BrowserClass::instances(result);
        result.full_names(classes);

        QStringList basics = GenerationSettings::basic_types();
        classes+=basics;
        QCompleter* completer = new QCompleter(classes, parent);
        completer->setCaseSensitivity(Qt::CaseSensitive);

        QComboBox* box = new QComboBox(parent);
        QStringListModel* model = new QStringListModel;
        model->setStringList(classes);
        box->setModel(model);
        box->setEditable(true);
        box->setCompleter(completer);
        return box;
    };

    delegate->dataAccessor = [](QWidget* editor, const QModelIndex& index)
    {
        QString value = index.model()->data(index, Qt::EditRole).toString();
        QComboBox* box = static_cast<QComboBox*>(editor);
        box->setCurrentText(value);
    };

    delegate->dataSetter = [](QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)
    {
        QComboBox* box = static_cast<QComboBox*>(editor);
        QString value = box->currentText();
        model->setData(index, value, Qt::EditRole);
    };

    ui->tvEditor->setItemDelegateForColumn(columns.indexOf("type"), delegate);
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:41,代码来源:quickedit.cpp


注:本文中的QComboBox::setCurrentText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。