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


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

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


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

示例1: setEditorData

void ComboUsersDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     Q_UNUSED(index);
     QComboBox * combo = static_cast<QComboBox*>(editor);
     QMapIterator<QString,QString> it(m_mapUsers);
     int row = 0;
     while (it.hasNext())
     {
         it.next();
         QString login = it.key();
         QString prat = it.value();
         combo->addItem(login);
         combo->setItemData(row,prat,Qt::ToolTipRole);
         ++row;
         }
}
开发者ID:jeromecc,项目名称:FreeAccounting,代码行数:16,代码来源:delegate.cpp

示例2: addCombo

// Create new combo widget
QtWidgetObject* AtenTreeGuiDialog::addCombo(TreeGuiWidget* widget, QString label)
{
	QtWidgetObject* qtwo = widgetObjects_.add();
	QComboBox* combo = new QComboBox(this);
	qtwo->set(widget, combo, label);
	// Add items to combo and set current index
	for (int n=0; n<widget->comboItems().count(); ++n) combo->addItem(widget->comboItems().at(n));
	combo->setCurrentIndex(widget->valueI() - 1);
	combo->setEnabled(widget->enabled());
	combo->setVisible(widget->visible());
	combo->setMinimumHeight(WIDGETHEIGHT);
	combo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
	// Connect signal to master slot
	QObject::connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(comboWidget_currentIndexChanged(int)));
	return qtwo;
}
开发者ID:alinelena,项目名称:aten,代码行数:17,代码来源:treegui_funcs.cpp

示例3: updateObjectComboBox

void MainWindow::updateObjectComboBox()
{
    QComboBox *comboBox = ui->objectSelectorComboBox;

    int previousIndex = comboBox->currentIndex();
    int previousSize = comboBox->count();

    comboBox->clear();
    for(int i = 0; i < levelObjects.count(); i++)
    {
        comboBox->addItem(QString(levelObjects.at(i).value("type").toString() + " - " + levelObjects.at(i).value("name").toString()));
    }

    if(previousSize == comboBox->count())
        comboBox->setCurrentIndex(previousIndex);
}
开发者ID:ryachart,项目名称:Ballgame,代码行数:16,代码来源:mainwindow.cpp

示例4: refreshDisplay

void EasyViewWidget::refreshDisplay() {
    if(this->layout()) {
        qDeleteAll(Boxes);
        Boxes.clear();
        delete this->layout();
    }

    QVBoxLayout *layout = new QVBoxLayout;
    setLayout(layout);

    QComboBox* fileChoice = new QComboBox();

#if defined(_WIN32) && defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP) // Workaround render bug
    QString style = "QComboBox QAbstractItemView { border: 1px solid gray }";
    fileChoice->setStyleSheet(style);
#endif

    layout->addWidget(fileChoice);
    for (size_t Pos=0; Pos<C->Count_Get(); Pos++)
        fileChoice->addItem( wstring2QString(C->Get(Pos, Stream_General, 0, __T("CompleteName"))), (int)Pos);

    fileChoice->setCurrentIndex(FilePos);

    connect(fileChoice,SIGNAL(currentIndexChanged(int)),SLOT(changeFilePos(int)));

    QFrame *box;
    QGroupBox *subBox;
    for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++) {
        bool addBox = false;
        box = new QFrame();
        QHBoxLayout* boxLayout = new QHBoxLayout();
        box->setLayout(boxLayout);
        for (size_t Pos=0; Pos<Boxes_Count_Get(StreamPos); Pos++) {
            subBox = createBox((stream_t)StreamPos,(int)Pos);
            if(subBox!=NULL) {
                boxLayout->addWidget(subBox);
                addBox = true;
            }
        }
        if(addBox) {
            layout->addWidget(box);
            Boxes.push_back(box);
        }

    }
    layout->addStretch();
}
开发者ID:MediaArea,项目名称:MediaInfo,代码行数:47,代码来源:easyviewwidget.cpp

示例5: constructPathGroup

void RightWidget::constructPathGroup()
{
    QGroupBox *pathGroupBox = new QGroupBox("Compute a shortest path :");

    QComboBox *sourceComboBox = new QComboBox();
    for(int id:mcTalker->getNodeIDList())
    {
        sourceComboBox->addItem(
                             QString::number(id).append(" | ").append(
                             QString::fromStdString(
                             mcTalker->getNodeNameFromId(
                             id
                             ))));
    }
    sourceComboBox->setCurrentIndex(-1);

    connect(sourceComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(sendAResetElectionSig()));
    connect(sourceComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(assignReachableNode(int)));
    connect(sourceComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(assignSourceNodeId(int)));
    destComboBox = new QComboBox();

    connect(destComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(assignDestNodeId(int)));

    QGridLayout *groupBoxLayout = new QGridLayout();
    groupBoxLayout->addWidget(new QLabel("Start point :"),1,1,1,1);
    groupBoxLayout->addWidget(sourceComboBox,1,2,1,2);
    groupBoxLayout->addWidget(new QLabel("End point :"),2,1,1,1);
    groupBoxLayout->addWidget(destComboBox,2,2,1,2);

    computeButton=new QPushButton("Compute !\n(will do something only on reachable place)");
    computeButton->setEnabled(false);
    connect(sourceComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(deactivatePathButton()));
    connect(destComboBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(activatePathButton()));
    connect(computeButton,SIGNAL(clicked()),this,SLOT(startShortestPath()));
    connect(computeButton,SIGNAL(clicked()),this,SLOT(deactivatePathButton()));
    groupBoxLayout->addWidget(computeButton,3,1,1,3);

    pathGroupBox->setLayout(groupBoxLayout);

    layout->addWidget(pathGroupBox);
}
开发者ID:efavry,项目名称:skiResort,代码行数:47,代码来源:rightwidget.cpp

示例6: AddString

int CComboBox::AddString(LPCTSTR lpszString)
{
	int index = CB_ERR;
	
	assert(m_hWnd);
	
	if (m_hWnd)
	{
        QComboBox *comboBox = (QComboBox *)m_hWnd;

        comboBox->addItem(QString::fromStdWString(lpszString));

        index = comboBox->count();
	}
	
	return index;
}
开发者ID:mdmitry1973,项目名称:CShell,代码行数:17,代码来源:CComboBox.cpp

示例7: setTitle

EpidemicCasesWidget::EpidemicCasesWidget(boost::shared_ptr<EpidemicDataSet> dataSet)
{
    setTitle("Cases");

    QVBoxLayout * layout = new QVBoxLayout();
    setLayout(layout);

    // add num cases widget
    numCasesSpinBox_.setMaximum(999999);
    numCasesSpinBox_.setSuffix(" cases");
    layout->addWidget(&numCasesSpinBox_);

    // add node choices widget
    layout->addWidget(&nodeComboBox_);

    std::vector<int> nodeIds = dataSet->getNodeIds();

    for(unsigned int i=0; i<nodeIds.size(); i++)
    {
        nodeComboBox_.addItem(dataSet->getNodeName(nodeIds[i]).c_str(), nodeIds[i]);
    }

    // add stratification choices
    std::vector<std::vector<std::string> > stratifications = EpidemicDataSet::getStratifications();

    for(unsigned int i=0; i<stratifications.size(); i++)
    {
        QComboBox * stratificationValueComboBox = new QComboBox(this);

        for(unsigned int j=0; j<stratifications[i].size(); j++)
        {
            stratificationValueComboBox->addItem(QString(stratifications[i][j].c_str()), j);
        }

        stratificationValueComboBoxes_.push_back(stratificationValueComboBox);

        layout->addWidget(stratificationValueComboBox);
    }

    // default to second age group (first stratification)
    stratificationValueComboBoxes_[0]->setCurrentIndex(1);

    // hide last stratification (vaccination status)
    // todo: could be handled better...
    stratificationValueComboBoxes_[stratificationValueComboBoxes_.size()-1]->hide();
}
开发者ID:gregjohnson,项目名称:PanFluExercise,代码行数:46,代码来源:EpidemicCasesWidget.cpp

示例8: QComboBox

QWidget *IColDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex &index) const
{
    if( index.column() == 0 ){
	QComboBox *comboBox = new QComboBox(parent);
	
	sSet colsSet=_msc->getColsSet( _type, _name, _p );
	
	for( sSet::const_iterator p=colsSet.begin(); p != colsSet.end(); p++ ){
	    comboBox->addItem((*p).c_str());
	}
	comboBox->setEditable(true);
	comboBox->setAutoCompletion(true);

	return comboBox;
    }
    return NULL;
}
开发者ID:iLCSoft,项目名称:Marlin,代码行数:17,代码来源:icoldelegate.cpp

示例9: QComboBox

QWidget *TaskItemDelegate::createEditor(QWidget *parent,
                                          const QStyleOptionViewItem &/* option */,
                                          const QModelIndex & index ) const
{
    QComboBox *editor = new QComboBox(parent);
    int j = -1;
    int i=0;
    QString current = index.data().toString();
    foreach(const Task& t, *m_sak->tasks()) {
        editor->addItem(t.icon, t.title);
        if (t.title == current)
            j = i;
    }
    Q_ASSERT(j = -1);
    editor->setCurrentIndex(j);
    return editor;
}
开发者ID:zanettea,项目名称:SAK,代码行数:17,代码来源:sakhits.cpp

示例10: createEditor

QWidget *ComboBoxDelegate::createEditor(QWidget *parent,
    const QStyleOptionViewItem & option ,
    const QModelIndex & index) const
{
    if (index.column()==0){
       QComboBox *editor = new QComboBox(parent); int ei = 0;
       QString s = index.model()->data(index, Qt::EditRole).toString();
       for(int j=1; j<=n_element; j++) {
          QString aux = QString("%1  %2 ").arg(j,3).arg(QString::fromStdString(element_data[j-1].symbol),2);
          editor->addItem(aux);
          if( s.toStdString() == element_data[j-1].symbol ) ei = j-1;
       }
       editor->setCurrentIndex(ei);
       return editor;
    }
    else return QItemDelegate::createEditor(parent,option,index);
}
开发者ID:Klunkerball,项目名称:EGSnrc,代码行数:17,代码来源:pegs_page.cpp

示例11: prepareTilesetGroup

void TilesetItemBox::prepareTilesetGroup(const SimpleTilesetGroup &tilesetGroups)
{
    if(lockTilesetBox) return;

    QWidget *t = findTabWidget(tilesetGroups.groupCat);
    if(!t)
        t = makeCategory(tilesetGroups.groupCat);
    QComboBox *c = getGroupComboboxOfTab(t);
    if(!c)
        return;
    c->setInsertPolicy(QComboBox::InsertAlphabetically);
    if(!util::contains(c, tilesetGroups.groupName))
        c->addItem(tilesetGroups.groupName);
    c->model()->sort(0);
    c->setCurrentIndex(0);
    connect(c, SIGNAL(currentIndexChanged(int)), this, SLOT(on_tilesetGroup_currentIndexChanged(int)));
}
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:17,代码来源:tileset_item_box.cpp

示例12: getLinePatternComboBox

QComboBox* StringHandler::getLinePatternComboBox()
{
  QComboBox *pLinePatternComboBox = new QComboBox;
  pLinePatternComboBox->setIconSize(QSize(58, 16));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-none.svg"), getLinePatternString(LineNone));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-solid.svg"), getLinePatternString(LineSolid));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-dash.svg"), getLinePatternString(LineDash));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-dot.svg"), getLinePatternString(LineDot));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-dash-dot.svg"), getLinePatternString(LineDashDot));
  pLinePatternComboBox->addItem(QIcon(":/Resources/icons/line-dash-dot-dot.svg"), getLinePatternString(LineDashDotDot));
  return pLinePatternComboBox;
}
开发者ID:dietmarw,项目名称:OMEdit,代码行数:12,代码来源:StringHandler.cpp

示例13: updatePhaseComboBoxes

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PhaseTypeSelectionWidget::updatePhaseComboBoxes()
{
  bool ok = false;
  // setup the list of choices for the widget
  PhaseTypeSelectionFilterParameter* phaseTypes = dynamic_cast<PhaseTypeSelectionFilterParameter*>(getFilterParameter());
  QString countProp = phaseTypes->getPhaseTypeCountProperty();
  int phaseCount = getFilter()->property(countProp.toLatin1().constData()).toInt(&ok);
  QString phaseDataProp = phaseTypes->getPhaseTypeDataProperty();

  UInt32Vector_t vectorWrapper = getFilter()->property(phaseDataProp.toLatin1().constData()).value<UInt32Vector_t>();
  QVector<quint32> dataFromFilter = vectorWrapper.d;
  if(phaseCount < 0 && dataFromFilter.size() < 10)   // there was an issue getting the phase Count from the Filter.
  {
    phaseCount = dataFromFilter.size(); // So lets just use the count from the actual phase data
  }

  // Get our list of predefined enumeration values
  QVector<unsigned int> phaseTypeEnums;
  PhaseType::getPhaseTypeEnums(phaseTypeEnums);

  phaseListWidget->clear();
  // Get our list of Phase Type Strings
  QStringList phaseListChoices = m_FilterParameter->getPhaseListChoices();

  for (int i = 1; i < phaseCount; i++)
  {
    QComboBox* cb = new QComboBox(NULL);
    for (int s = 0; s < phaseListChoices.size(); ++s)
    {
      cb->addItem((phaseListChoices[s]), phaseTypeEnums[s]);
      cb->setItemData(static_cast<int>(s), phaseTypeEnums[s], Qt::UserRole);
    }

    QListWidgetItem* item = new QListWidgetItem(phaseListWidget);
    phaseListWidget->addItem(item);
    phaseListWidget->setItemWidget(item, cb);

    if (i < dataFromFilter.size())
    {
      cb->setCurrentIndex(dataFromFilter[i]);
    }
    connect(cb, SIGNAL(currentIndexChanged(int)),
            this, SLOT(phaseTypeComboBoxChanged(int)) );
  }
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:48,代码来源:PhaseTypeSelectionWidget.cpp

示例14: 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

示例15: createEditorFor

QWidget* CameraParamsWidget::createEditorFor(const calibration::CameraParam& param)
{
	if(!param.choices.empty())
	{
		QComboBox* box = new QComboBox(m_w);
		for(uint i = 0; i < param.choices.size(); ++i)
		{
			box->addItem(
				param.choices[i].label.c_str(),
				param.choices[i].value
			);
			if(param.choices[i].value == param.value)
				box->setCurrentIndex(i);
		}

		box->setProperty("paramID", param.id);

		connect(box, SIGNAL(activated(int)), SLOT(updateComboBox()));

		return box;
	}

	if(param.minimum == 0 && param.maximum == 1)
	{
		QCheckBox* box = new QCheckBox(m_w);
		box->setChecked(param.value);

		box->setProperty("paramID", param.id);

		connect(box, SIGNAL(clicked(bool)), SLOT(updateCheckBox(bool)));

		return box;
	}

	QSlider* slider = new QSlider(Qt::Horizontal, m_w);
	slider->setMinimum(param.minimum);
	slider->setMaximum(param.maximum);
	slider->setValue(param.value);

	slider->setProperty("paramID", param.id);

	connect(slider, SIGNAL(valueChanged(int)), SLOT(updateSlider(int)));

	return slider;
}
开发者ID:NimbRo-Copter,项目名称:nimbro-op-ros,代码行数:45,代码来源:cameraparamswidget.cpp


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