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


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

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


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

示例1: filterTrainData

void MainWindow::filterTrainData(QString trainID, QString startingStation, QString terminalStation)
{
    //refresh
    for(int i = 0; i < trainTable->rowCount(); ++i)
        trainTable->showRow(i);
    //filter trainID
    for(int i = 0; i < trainTable->rowCount(); ++i)
    {
        if(!trainTable->item(i, 0)->text().contains(trainID))
            trainTable->hideRow(i);
    }
    //filter starting station
    for(int rowNum = 0; rowNum < trainTable->rowCount(); ++rowNum)
    {
        bool isFind = false;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            if(comboBox->itemText(i).contains(startingStation))
            {
                comboBox->setCurrentIndex(i);
                isFind = true;
                break;
            }
        }
        if(isFind == false)
            trainTable->hideRow(rowNum);
    }

    //filter terminal station
    for(int rowNum = 0; rowNum < trainTable->rowCount(); ++rowNum)
    {
        bool isFind = false;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        int startingStationIndex = comboBox->currentIndex();
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            //terminal should be after startingStation
            if(comboBox->itemText(i).contains(terminalStation) && startingStationIndex < i)
            {
                isFind = true;
                break;
            }
        }
        if(isFind == false)
            trainTable->hideRow(rowNum);
    }
}
开发者ID:luyiming,项目名称:TicketManagementSystem,代码行数:48,代码来源:mainwindow.cpp

示例2: styleSel

bool StylesStBar::styleSel( )
{
    //> Get syles list
    XMLNode req("get");
    req.setAttr("path","/ses_"+mainWin()->workSess()+"/%2fobj%2fcfg%2fstLst");
    mainWin()->cntrIfCmd(req);

    if( req.childSize() <= 1 ) return false;

    InputDlg dlg( this, mainWin()->windowIcon(),_("Select your style from list."),_("Style select"),false,false);
    QLabel *lab = new QLabel(_("Style:"),&dlg);
    lab->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred) );
    dlg.edLay()->addWidget( lab, 0, 0 );
    QComboBox *stls = new QComboBox(&dlg);
    dlg.edLay()->addWidget( stls, 0, 1 );
    for(unsigned i_s = 0; i_s < req.childSize(); i_s++)
    {
	stls->addItem(req.childGet(i_s)->text().c_str(),atoi(req.childGet(i_s)->attr("id").c_str()));
	if(atoi(req.childGet(i_s)->attr("id").c_str()) == style())
	    stls->setCurrentIndex(i_s);
    }
    dlg.resize(300,120);
    if( dlg.exec() == QDialog::Accepted && stls->currentIndex() >= 0 )
    {
	setStyle( stls->itemData(stls->currentIndex()).toInt(), stls->itemText(stls->currentIndex()).toAscii().data() );
	emit styleChanged( );
	return true;
    }

    return false;
}
开发者ID:careychow,项目名称:openscada,代码行数:31,代码来源:vis_run_widgs.cpp

示例3: modifyTrainDialog

void MainWindow::modifyTrainDialog()
{
    if(this->visitorMode == true)
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("失败"), QString::fromLocal8Bit("游客身份无法修改车次"));
        return;
    }
    //set default content
    int curRow = trainTable->currentRow();
    if(curRow == -1)
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("修改失败"), QString::fromLocal8Bit("请选择要修改的车次"));
        return;
    }
    else
    {
//        format
//        trainIDLine
//        departureTimeLine
//        drivingTimeLine
//        priceLine
//        maxPassengersLine
//        routesText  以|分隔
        QStringList trainData;
        trainData << trainTable->item(curRow, 0)->text();
        trainData << trainTable->item(curRow, 3)->text();
        trainData << trainTable->item(curRow, 4)->text();
        trainData << trainTable->item(curRow, 5)->text();
        trainData << trainTable->item(curRow, 6)->text();

        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(curRow, 8);
        QString singleRoute;
        for(int i = 0 ; i < comboBox->count(); ++i)//split route and seats data in the comboBox
        {
            if(i)
                singleRoute += '|';

            QString stationWithSeat = comboBox->itemText(i);
            QStringList t = stationWithSeat.split(" ", QString::SkipEmptyParts);
            if(t.size() < 2)
            {
                qDebug() << "wrong in modiftTrain()";
                return;
            }

            if(t.at(1) != trainData[4] && i != comboBox->count() - 1)
            {
                QMessageBox::warning(this, QString::fromLocal8Bit("修改失败"), QString::fromLocal8Bit("该车次已售票,不可修改"));
                return;
            }
            singleRoute += t.at(0);
        }
        trainData << singleRoute;

        trainAMDialog *modifyDialog = new trainAMDialog(this);
        modifyDialog->setTrainData(trainData);  //set default data
        connect(modifyDialog, &trainAMDialog::modifyValueChanged, this, &MainWindow::modifyTrainInfo);
        modifyDialog->exec();
    }
}
开发者ID:luyiming,项目名称:TicketManagementSystem,代码行数:60,代码来源:mainwindow.cpp

示例4: sellTicketDialog

void MainWindow::sellTicketDialog()
{
    int rowNum = trainTable->currentRow();
    if(rowNum >= 0)
    {
        QString trainID_ = trainTable->item(rowNum, 0)->text();
        QString departureTime_ = trainTable->item(rowNum, 3)->text();
        QString price_ = trainTable->item(rowNum, 5)->text();
        QStringList routesWithSeats;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            routesWithSeats << comboBox->itemText(i);
        }

        SellDialog *sellDialog = new SellDialog(this);
        sellDialog->setTicketData(trainID_, departureTime_, price_, routesWithSeats);
        connect(sellDialog, &SellDialog::buyTicket, this, &MainWindow::sellTicket);
        sellDialog->exec();
    }
    else
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("购票失败"), QString::fromLocal8Bit("请选择要购买的车次"));
    }
}
开发者ID:luyiming,项目名称:TicketManagementSystem,代码行数:25,代码来源:mainwindow.cpp

示例5: setModelData

void ArchiveDelegate::setModelData(QWidget *AEditor, QAbstractItemModel *AModel, const QModelIndex &AIndex) const
{
	switch (AIndex.column())
	{
	case COL_SAVE:
	case COL_OTR:
	case COL_EXACT:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int index = comboBox->currentIndex();
				AModel->setData(AIndex,comboBox->itemText(index),Qt::DisplayRole);
				AModel->setData(AIndex,comboBox->itemData(index),Qt::UserRole);
			}
		}
		break;
	case COL_EXPIRE:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int expire = comboBox->currentText().toInt()*ONE_DAY;
				AModel->setData(AIndex,expireName(expire),Qt::DisplayRole);
				AModel->setData(AIndex,expire,Qt::UserRole);
			}
		}
		break;
	default:
		break;
	}
}
开发者ID:ChALkeR,项目名称:vacuum-im,代码行数:32,代码来源:archiveaccountoptionswidget.cpp

示例6: setModelData

void ComboDelegate::setModelData (QWidget* editor,
				  QAbstractItemModel *model,
				  const QModelIndex &index) const
{
	QComboBox* combo = static_cast<QComboBox*>(editor);
	
	// Set the data in the given model
	model->setData(index,combo->itemText(combo->currentIndex()),Qt::EditRole);
}
开发者ID:roeland-frans,项目名称:q-rap,代码行数:9,代码来源:ComboDelegate.cpp

示例7: toString

QString ExprParamElement::toString()
{
    QString str = "";
    if (isStringSearchExpression())
    {
        str = QString("\"") + getStrSearchValue() + QString("\""); 
        // we don't bother with case if hash search
	if (searchType != HashSearch) {
	    str += (ignoreCase() ? QString(" (ignore case)") 
                            : QString(" (case sensitive)")); 
	}
    } else 
    {
        if (searchType ==  DateSearch) {
            QDateEdit * dateEdit =  qFindChild<QDateEdit *> (internalframe, "param1");
            str = dateEdit->text();
            if (inRangedConfig)
            {
                str += QString(" ") + tr("to") + QString(" ");
                dateEdit = qFindChild<QDateEdit *> (internalframe, "param2");
                str += dateEdit->text();
            }
        } else if (searchType == SizeSearch) 
        {
            QLineEdit * lineEditSize =  qFindChild<QLineEdit*>(internalframe, "param1");
            str = ("" == lineEditSize->text()) ? "0"
                                               : lineEditSize->text();
            QComboBox * cb = qFindChild<QComboBox*> (internalframe, "unitsCb1");
            str += QString(" ") + cb->itemText(cb->currentIndex());
            if (inRangedConfig)
            {
                str += QString(" ") + tr("to") + QString(" ");
                lineEditSize =  qFindChild<QLineEdit*>(internalframe, "param2");
                str += ("" == lineEditSize->text()) ? "0"
                                                    : lineEditSize->text();
                cb = qFindChild<QComboBox*> (internalframe, "unitsCb2");
                str += QString(" ") + cb->itemText(cb->currentIndex());
            }
        }
    }
    return str;
}
开发者ID:boukeversteegh,项目名称:retroshare,代码行数:42,代码来源:guiexprelement.cpp

示例8: copyComboBox

QComboBox* LayoutManager::copyComboBox(QObject *obj) {
    QComboBox *oldComboBox = qobject_cast<QComboBox*>(obj);
    QComboBox *newComboBox = new QComboBox();

    for(int i=0;i<oldComboBox->count();i++) {
        newComboBox->addItem(oldComboBox->itemText(i),oldComboBox->itemData(i));
    }
    newComboBox->setObjectName(oldComboBox->objectName() + " " + QString::number(keyLayouts.size()));

    return newComboBox;
}
开发者ID:floreks,项目名称:D3Helper,代码行数:11,代码来源:layoutmanager.cpp

示例9: setModelData

void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    if (QString(editor->metaObject()->className())==tr("QComboBox")){
       QComboBox *cb = static_cast<QComboBox*>(editor);
       QString str = cb->itemText(cb->currentIndex());
       model->setData(index, QVariant(str.right(3).trimmed()), Qt::EditRole);
    }
    else{
      QItemDelegate::setModelData(editor,model,index);
    }
}
开发者ID:Klunkerball,项目名称:EGSnrc,代码行数:12,代码来源:pegs_page.cpp

示例10: setEditorData

void TaskItemDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &index) const
{
    const QString& value ( index.data().toString() );
    
    QComboBox *e = static_cast<QComboBox*>(editor);
    for(int i=0; i<e->count(); i++) {
        if (e->itemText(i) == value) {
            e->setCurrentIndex(i);
            break;
        }
    }
}
开发者ID:zanettea,项目名称:SAK,代码行数:13,代码来源:sakhits.cpp

示例11: GetLBText

void CComboBox::GetLBText(int nIndex, CString& rString) const
{
    assert(m_hWnd);
	
	if (m_hWnd)
	{
        QString text;
        QComboBox *comboBox = (QComboBox *)m_hWnd;
        text = comboBox->itemText(nIndex);

        rString = text.toStdWString().c_str();
	}
}
开发者ID:mdmitry1973,项目名称:CShell,代码行数:13,代码来源:CComboBox.cpp

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

示例13: QDialog

LoadWindow::LoadWindow(QWidget *parent, const QStringList &tierList, const QString &name) :
    QDialog(parent),
    ui(new Ui::LoadWindow)
{
    ui->setupUi(this);

    holder.load();

    LoadLine *array[] = {ui->line1, ui->line2, ui->line3, ui->line4, ui->line5, ui->line6};
    memcpy(lines, array, sizeof(array));

    lines[0]->setUi(ui->name1, ui->gen1, ui->tier1, ui->browser1, tierList);
    lines[1]->setUi(ui->name2, ui->gen2, ui->tier2, ui->browser2, tierList);
    lines[2]->setUi(ui->name3, ui->gen3, ui->tier3, ui->browser3, tierList);
    lines[3]->setUi(ui->name4, ui->gen4, ui->tier4, ui->browser4, tierList);
    lines[4]->setUi(ui->name5, ui->gen5, ui->tier5, ui->browser5, tierList);
    lines[5]->setUi(ui->name6, ui->gen6, ui->tier6, ui->browser6, tierList);

    for (int i = 0; i < 6; i++) {
        if (i >= holder.count()) {
            lines[i]->setChecked(false);
        } else {
            lines[i]->setTeam(holder.team(i));
            lines[i]->setChecked(true);
        }
    }

    /* Hide profile & color from TeamBuilder, since there's a few bugs and you can edit it all in TeamBuilder anyway... */
    if (name == "") {
        ui->profileList->hide();
        ui->colorButton->hide();
    }

    /* To reduce excessive code, this will make the color the same color as your current profile by default */
    on_profileList_currentIndexChanged(name);

    QSettings s;

    QStringList profiles = holder.profile().getProfileList(s.value("Profile/Path").toString());
    QComboBox *profileList = ui->profileList;
    profileList->blockSignals(true);
    profileList->addItems(profiles);
    profileList->blockSignals(false);
    for (int i = 0; i < profileList->count(); ++i) {
        if (profileList->itemText(i) == name)
            profileList->setCurrentIndex(i);
    }

    connect(this, SIGNAL(accepted()), SLOT(onAccept()));
}
开发者ID:Alicirno,项目名称:pokemon-online,代码行数:50,代码来源:loadwindow.cpp

示例14: expressionButtonClicked

void QgsDataDefinedSymbolDialog::expressionButtonClicked()
{
  QgsDebugMsg( "Expression button clicked" );

  //find out row
  QObject* senderObj = sender();
  int row = 0;
  for ( ; row < mTableWidget->rowCount(); ++row )
  {
    if ( senderObj == mTableWidget->cellWidget( row, 3 ) )
    {
      break;
    }
  }

  QComboBox* attributeCombo = qobject_cast<QComboBox*>( mTableWidget->cellWidget( row, 2 ) );
  if ( !attributeCombo )
  {
    return;
  }

  QString previousText = attributeCombo->itemText( attributeCombo->currentIndex() );
  if ( attributeCombo->currentIndex() > 0 )
  {
    previousText.prepend( "\"" ).append( "\"" );
  }

  QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer*>( mVectorLayer ), previousText );
  if ( d.exec() == QDialog::Accepted )
  {
    QString expressionString = d.expressionText();
    int comboIndex = comboIndexForExpressionString( d.expressionText(), attributeCombo );

    if ( comboIndex == -1 )
    {
      attributeCombo->setItemText( 0, d.expressionText() );
      attributeCombo->setCurrentIndex( 0 );
      Q_ASSERT( d.expressionText() == attributeCombo->currentText() );
    }
    else
    {
      if ( comboIndex != 0 )
      {
        attributeCombo->setItemText( 0, QString() );
      }
      attributeCombo->setCurrentIndex( comboIndex );
    }
  }
}
开发者ID:pahau,项目名称:QGIS,代码行数:49,代码来源:qgsdatadefinedsymboldialog.cpp

示例15: GetLBTextLen

int CComboBox::GetLBTextLen(int nIndex) const
{
    assert(m_hWnd);

    if (m_hWnd)
    {
        QString text;
        QComboBox *comboBox = (QComboBox *)m_hWnd;
        text = comboBox->itemText(nIndex);

        return text.length();
    }

	return 0;
}
开发者ID:mdmitry1973,项目名称:CShell,代码行数:15,代码来源:CComboBox.cpp


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