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


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

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


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

示例1: replacementItemChanged

void DesktopThemeDetails::replacementItemChanged()
{
    //Check items to see if theme has been customized
    m_themeCustomized = true;
    QHashIterator<QString, int> i(m_items);
    while (i.hasNext()) {
        i.next();
        QComboBox *itemComboBox = static_cast<QComboBox*>(m_themeItemList->cellWidget(i.value(), 1));
        int replacement = itemComboBox->currentIndex();
        if (replacement <= (m_themes.size() - 1)) {
            // Item replacement source is a theme
            m_itemThemeReplacements[i.value()] = itemComboBox->currentIndex();
        } else if (replacement > (m_themes.size() - 1)) {
            // Item replacement source is a file
            if (itemComboBox->currentText() == i18n("File...")) {
                //Get the filename for the replacement item
                QString translated_key = i18nc("plasma name", qPrintable( i.key() ) );
                QString fileReplacement = QFileDialog::getOpenFileName(this, i18n("Select File to Use for %1",translated_key));
                if (!fileReplacement.isEmpty()) {
                    m_itemFileReplacements[i.value()] = fileReplacement;
                    int index = itemComboBox->findText(fileReplacement);
                    if (index == -1) itemComboBox->addItem(fileReplacement);
                    disconnect(itemComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DesktopThemeDetails::replacementItemChanged);
                    itemComboBox->setCurrentIndex(itemComboBox->findText(fileReplacement));
                    connect(itemComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DesktopThemeDetails::replacementItemChanged);
                    m_itemThemeReplacements[i.value()] = -1; //source is not a theme
                    m_itemFileReplacements[i.value()] = itemComboBox->currentText();
                } else {
                    // Reset combobox to previous value if no file is selected
                    if (m_itemThemeReplacements[i.value()] != -1) {
                        itemComboBox->setCurrentIndex(m_itemThemeReplacements[i.value()]);
                    } else {
                        itemComboBox->setCurrentIndex(itemComboBox->findText(m_itemFileReplacements[i.value()]));
                    }
                    m_themeCustomized = false;
                }
            } else {
                m_itemThemeReplacements[i.value()] = -1; //source is not a theme
                m_itemFileReplacements[i.value()] = itemComboBox->currentText();
            }
        }
    }

    if (m_themeCustomized) emit changed();
}
开发者ID:mafrez,项目名称:plasma-desktop,代码行数:45,代码来源:desktopthemedetails.cpp

示例2: QSqlQueryModel

void PretrazivanjeSredstavaD1::setModelSredstva()
{
	QComboBox *view = ui->cbSredstva;
	modelSredstva = new QSqlQueryModel();
	modelSredstva->setQuery("select -1 as A, 'Svi' as B union select * from artikal;");
	view->setModel(modelSredstva);
	view->setModelColumn(1);
	view->setCurrentIndex(view->findText("Svi"));
}
开发者ID:Wushaowei001,项目名称:nabavke,代码行数:9,代码来源:pretrazivanjesredstavad1.cpp

示例3: setEditorData

void ComboDelegate::setEditorData(QWidget *editor,
                                     const QModelIndex &index) const
{
    QString str = index.model()->data(index).toString();
    
    QComboBox *box = static_cast<QComboBox*>(editor);
    int i = box->findText(str);
    box->setCurrentIndex(i);
}
开发者ID:gmsh,项目名称:fangchanzhongjie,代码行数:9,代码来源:combodelegate.cpp

示例4: setEditorData

void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    QString value = index.model()->data(index, Qt::DisplayRole).toString();
    kDebug()<<value<<":"<<m_list;
    QComboBox *comboBox = static_cast<QComboBox*>(editor);

    comboBox->insertItems(0, m_list);
    comboBox->setCurrentIndex(comboBox->findText(value));
}
开发者ID:KDE,项目名称:calligra-history,代码行数:9,代码来源:kptwbsdefinitionpanel.cpp

示例5: setEditorData

//-----------------------------------------------------------------------------
// Function: PortsDelegate::setEditorData()
//-----------------------------------------------------------------------------
void PortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const
{
    if (index.column() == PortColumns::DIRECTION)
    {
        QString text = index.data(Qt::DisplayRole).toString();
        QComboBox* combo = qobject_cast<QComboBox*>(editor);

        int comboIndex = combo->findText(text);
        combo->setCurrentIndex(comboIndex);
    }
    else if (index.column() == PortColumns::TYPE_NAME || index.column() == PortColumns::TYPE_DEF)
    {
        QString text = index.data(Qt::DisplayRole).toString();
        QComboBox* combo = qobject_cast<QComboBox*>(editor);

        int comboIndex = combo->findText(text);
        // if the text is not found
        if (comboIndex < 0)
        {
            combo->setEditText(text);
        }
        else
        {
            combo->setCurrentIndex(comboIndex);
        }
    }
    else if (index.column() == PortColumns::TAG_GROUP)
    {
        ListEditor* tagEditor = qobject_cast<ListEditor*>(editor);
        Q_ASSERT(tagEditor);

        QString portTagGroup = index.model()->data(index, Qt::DisplayRole).toString();

        if (!portTagGroup.isEmpty())
        {
            QStringList portTags = portTagGroup.split(", ");
            tagEditor->setItems(portTags);
        }
    }
    else
    {
        ExpressionDelegate::setEditorData(editor, index);
    }
}
开发者ID:kammoh,项目名称:kactus2,代码行数:47,代码来源:portsdelegate.cpp

示例6: setEditorData

void ComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
	QComboBox *c = qobject_cast<QComboBox*>(editor);
	QString data = index.model()->data(index, Qt::DisplayRole).toString();
	int i = c->findText(data);
	if (i != -1)
		c->setCurrentIndex(i);
	else
		c->setEditText(data);
}
开发者ID:dbinoj,项目名称:subsurface,代码行数:10,代码来源:modeldelegates.cpp

示例7: commonScenario

void ExportSequenceOfSelectedAnnotationsFiller::commonScenario()
{
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");

    QLineEdit *fileNameEdit = dialog->findChild<QLineEdit*>("fileNameEdit");
    GT_CHECK(fileNameEdit != NULL, "fileNameEdit not found");
    GTLineEdit::setText(os, fileNameEdit, path);

    GTGlobals::sleep(200);

    QComboBox *comboBox = dialog->findChild<QComboBox*>();
    GT_CHECK(comboBox != NULL, "ComboBox not found");
    int index = comboBox->findText(comboBoxItems[format]);

    GT_CHECK(index != -1, QString("item \"%1\" in combobox not found").arg(comboBoxItems[format]));
    if (comboBox->currentIndex() != index){
        GTComboBox::setCurrentIndex(os, comboBox, index, true, useMethod);
    }

    GTGlobals::sleep(200);

    QCheckBox *projectCheckBox = dialog->findChild<QCheckBox*>(QString::fromUtf8("addToProjectBox"));
    GT_CHECK(projectCheckBox != NULL, "addToProjectBox not found");
    GTCheckBox::setChecked(os, projectCheckBox, addToProject);

    GTGlobals::sleep(200);

    QCheckBox *annotationsCheckBox = dialog->findChild<QCheckBox*>(QString::fromUtf8("withAnnotationsBox"));
    GT_CHECK(annotationsCheckBox != NULL, "Check box not found");
    if(annotationsCheckBox->isEnabled()){
        GTCheckBox::setChecked(os, annotationsCheckBox, exportWithAnnotations);
    }

    GTGlobals::sleep(200);

    QRadioButton *mergeButton = dialog->findChild<QRadioButton*>(mergeRadioButtons[options]);

    GT_CHECK(mergeButton != NULL, "Radio button " + mergeRadioButtons[options] + " not found");
    if (mergeButton->isEnabled()){
        GTRadioButton::click(os, mergeButton);
    }

    GTGlobals::sleep(200);

    if (gapLength){
        QSpinBox *mergeSpinBox = dialog->findChild<QSpinBox*>("mergeSpinBox");
        GT_CHECK(mergeSpinBox != NULL, "SpinBox not found");
        GTSpinBox::setValue(os, mergeSpinBox, gapLength, useMethod);
    }

    GTGlobals::sleep(200);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
开发者ID:ugeneunipro,项目名称:ugene,代码行数:55,代码来源:ExportSequencesDialogFiller.cpp

示例8: setEditorData

void GrainDelegate::setEditorData(QWidget *editor,
                                  const QModelIndex &index) const
{
    QComboBox *combo;
    QDoubleSpinBox *spin;
    int comboindex;

    QVariant value = index.model()->data(index, Qt::EditRole);

    // different kind of editor for each column
    switch (index.column()) {
      case GrainModel::NAME:
          combo = static_cast<QComboBox*>(editor);
          if (!combo) return;
          comboindex = combo->findText(value.toString());
          if (comboindex > 0) {
              combo->setCurrentIndex(comboindex);
          } else {
              combo->setEditText(value.toString());
          }
          break;

      case GrainModel::WEIGHT:
      case GrainModel::EXTRACT:
      case GrainModel::COLOR:
          spin = static_cast<QDoubleSpinBox*>(editor);
          if (!spin) return;
          spin->setValue(value.toDouble());
          break;

      case GrainModel::TYPE:
      case GrainModel::USE:
          combo = static_cast<QComboBox*>(editor);
          if (!combo) return;
          combo->setCurrentIndex(combo->findText(value.toString()));
          break;

      default:
          QItemDelegate::setEditorData(editor, index);
          break;
    }
}
开发者ID:Smerty,项目名称:qbrew,代码行数:42,代码来源:graindelegate.cpp

示例9: setEditorData

//! [2]
void ImageDelegate::setEditorData(QWidget *editor,
                                  const QModelIndex &index) const
{
    QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
    if (!comboBox)
        return;

    int pos = comboBox->findText(index.model()->data(index).toString(),
                                 Qt::MatchExactly);
    comboBox->setCurrentIndex(pos);
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:12,代码来源:imagedelegate.cpp

示例10: setEditorData

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

    QComboBox* policyComboBox = static_cast<QComboBox*>(editor);

    int idx = policyComboBox->findText(value);
    if( idx != -1 )
    {
        policyComboBox->setCurrentIndex(idx);
    }
}
开发者ID:fw4spl-org,项目名称:fw4spl,代码行数:12,代码来源:DumpEditor.cpp

示例11: setEditorData

void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
	if (index.column() >= 2)
	{
		QItemDelegate::setEditorData(editor, index);
		return;
	}

	QString data = index.model()->data(index, Qt::DisplayRole).toString();
	QComboBox* cb = static_cast<QComboBox*>(editor);
	cb->setCurrentIndex(cb->findText(data));
}
开发者ID:PierFio,项目名称:ball,代码行数:12,代码来源:pythonSettings.C

示例12: setEditorData

void FieldTypeDelegate::setEditorData(QWidget* pEditor, const QModelIndex& index) const
{
    QComboBox* pTypeCombo = dynamic_cast<QComboBox*>(pEditor);
    if (pTypeCombo == NULL)
    {
        return;
    }

    QString typeText = index.model()->data(index, Qt::EditRole).toString();
    int typeIndex = pTypeCombo->findText(typeText);
    pTypeCombo->setCurrentIndex(typeIndex);
}
开发者ID:jonatho7,项目名称:opticks,代码行数:12,代码来源:FeatureClassDlg.cpp

示例13: setEditorData

void DataTypeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    if (index.column() == dataTypeColumn)
    {
        QString text = index.model()->data(index, Qt::DisplayRole).toString();
        QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
        comboBox->setCurrentIndex(comboBox->findText(text));
    }
    else
    {
        QItemDelegate::setEditorData(editor, index);
    }
}
开发者ID:Finalcheat,项目名称:SQLiteDatabaseManage,代码行数:13,代码来源:datatypedelegate.cpp

示例14: setEditorData

void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    /*int value = index.model()->data(index, Qt::EditRole).toInt();
    QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
    spinBox->setValue(value);*/
    QString value = index.model()->data(index, Qt::DisplayRole).toString();
    QComboBox *cmbBox = static_cast<QComboBox*>(editor);
    cmbBox->setCurrentIndex(cmbBox->findText(value, Qt::MatchCaseSensitive));
    temp_editor = cmbBox;
    //connect(cmbBox, SIGNAL(valueChanged(int)), this, SLOT(indexChanged(int)));
    connect(cmbBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
    connect(cmbBox, SIGNAL(editTextChanged(QString)), this, SLOT(editTextChangedSlot(QString)));
}
开发者ID:AlekseyAleynik,项目名称:configurator,代码行数:13,代码来源:delegate.cpp

示例15: save

void Setting::save(const QString& section, const QString& prefix, const QComboBox& cmb, bool all)
{
    QSettings& store = storage();

    store.beginGroup(section);

    QString tkey = prefix + SET_PFX_CMBTXT;

    QString tval = cmb.currentText().trimmed();
    if (!tval.isEmpty())
        store.setValue(tkey, tval);

    if (all)
    {
        QStringList keys, vals;

        keys = store.childKeys();
        qint32 n = keys.size();
        if (n > 0)
        {
            keys.sort();

            while (n--)
            {
                QString k = keys[n];
                if ((k!=tkey) && k.startsWith(prefix))
                {
                    QString v = store.value(k).toString().trimmed();
                    if (!v.isEmpty() && (-1 == cmb.findText(v)))
                        vals.prepend(v);

                    store.remove(k);
                }
            }
        }

        n = cmb.count();
        if (n > SET_MAX_CMBITM)
            n = SET_MAX_CMBITM;

        qint32 i = 0;
        for (i=0; i<n; ++i)
            store.setValue(prefix+QString::number(i), cmb.itemText(i));

        n = (vals.count() > SET_MAX_CMBITM) ? SET_MAX_CMBITM : vals.count();
        for (qint32 j=0; i<n; ++i,++j)
            store.setValue(prefix+QString::number(i), vals[j]);
    }

    store.endGroup();
}
开发者ID:freebendy,项目名称:sokit_fork,代码行数:51,代码来源:setting.cpp


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