本文整理汇总了C++中QComboBox::setItemText方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setItemText方法的具体用法?C++ QComboBox::setItemText怎么用?C++ QComboBox::setItemText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setItemText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
}
示例2: updateFromAllowed
void MicroSelectWidget::updateFromAllowed()
{
QString oldFamily = m_pMicroFamily->currentText();
m_pMicroFamily->clear();
#define CHECK_ADD(family) \
if ( (m_allowedAsmSet & AsmInfo::family) \
&& !MicroLibrary::self()->microIDs( AsmInfo::family, \
m_allowedGpsimSupport, m_allowedFlowCodeSupport, m_allowedMicrobeSupport ).isEmpty() ) { \
m_pMicroFamily->insertItem( m_pMicroFamily->count(), AsmInfo::setToString(AsmInfo::family) ); \
}
CHECK_ADD(PIC12)
CHECK_ADD(PIC14)
CHECK_ADD(PIC16);
#undef CHECK_ADD
if ( m_pMicroFamily->contains(oldFamily) ) {
//m_pMicroFamily->setCurrentText(oldFamily); // 2018.12.07
{
QComboBox *c = m_pMicroFamily;
QString text = oldFamily;
int i = c->findText(text);
if (i != -1)
c->setCurrentIndex(i);
else if (c->isEditable())
c->setEditText(text);
else
c->setItemText(c->currentIndex(), text);
}
}
microFamilyChanged(oldFamily);
}
示例3: QDialog
QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPair< QString, QString > >& properties, const QgsVectorLayer* vl,
QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vl )
{
setupUi( this );
QgsFields attributeFields;
if ( mVectorLayer )
{
attributeFields = mVectorLayer->pendingFields();
}
mTableWidget->setRowCount( properties.size() );
int i = 0;
QMap< QString, QPair< QString, QString > >::const_iterator it = properties.constBegin();
for ( ; it != properties.constEnd(); ++it )
{
//check box
QCheckBox* cb = new QCheckBox( this );
cb->setChecked( !it.value().second.isEmpty() );
mTableWidget->setCellWidget( i, 0, cb );
mTableWidget->setColumnWidth( 0, cb->width() );
//property name
QTableWidgetItem* propertyItem = new QTableWidgetItem( it.value().first );
propertyItem->setData( Qt::UserRole, it.key() );
mTableWidget->setItem( i, 1, propertyItem );
//attribute list
QString expressionString = it.value().second;
QComboBox* attributeComboBox = new QComboBox( this );
attributeComboBox->addItem( QString() );
for ( int j = 0; j < attributeFields.count(); ++j )
{
attributeComboBox->addItem( attributeFields.at( j ).name() );
}
int attrComboIndex = comboIndexForExpressionString( expressionString, attributeComboBox );
if ( attrComboIndex >= 0 )
{
attributeComboBox->setCurrentIndex( attrComboIndex );
}
else
{
attributeComboBox->setItemText( 0, expressionString );
}
mTableWidget->setCellWidget( i, 2, attributeComboBox );
//expression button
QPushButton* expressionButton = new QPushButton( "...", this );
QObject::connect( expressionButton, SIGNAL( clicked() ), this, SLOT( expressionButtonClicked() ) );
mTableWidget->setCellWidget( i, 3, expressionButton );
++i;
}
}
示例4: setMicro
void MicroSelectWidget::setMicro( const QString & id )
{
MicroInfo * info = MicroLibrary::self()->microInfoWithID(id);
if (!info)
return;
m_pMicro->clear();
m_pMicro->insertItems( m_pMicro->count(),
MicroLibrary::self()->microIDs( info->instructionSet()->set() ) );
//m_pMicro->setCurrentText(id); // 2018.12.07
{
QComboBox *c = m_pMicro;
QString text = id;
int i = c->findText(text);
if (i != -1)
c->setCurrentIndex(i);
else if (c->isEditable())
c->setEditText(text);
else
c->setItemText(c->currentIndex(), text);
}
//m_pMicroFamily->setCurrentText( AsmInfo::setToString( info->instructionSet()->set() ) ); // 2018.12.07
{
QComboBox *c = m_pMicroFamily;
QString text = AsmInfo::setToString( info->instructionSet()->set() );
int i = c->findText(text);
if (i != -1)
c->setCurrentIndex(i);
else if (c->isEditable())
c->setEditText(text);
else
c->setItemText(c->currentIndex(), text);
}
}
示例5: slotGreeterEditTextChanged
void KraftDocFooterEdit::slotGreeterEditTextChanged(const QString& newText)
{
QComboBox *greeterCombo = qobject_cast<QComboBox*>(mDocFooterEdit->m_cbGreeting);
if( !greeterCombo ) return;
kDebug() << "II Combo box text changed to" << newText << "in" << greeterCombo;
const QStringList texts = KraftDB::self()->wordList("greeting");
int indx = greeterCombo->currentIndex();
if( !texts.contains(newText)) {
if( mCustomGreetingIndex == -1 ) {
// no custom Entry yet
greeterCombo->insertItem(0, newText);
mCustomGreetingIndex = 0;
}
indx = mCustomGreetingIndex;
}
greeterCombo->setItemText(indx, newText);
greeterCombo->setCurrentIndex(indx);
mGreeting = newText;
slotModified();
}
示例6: NewWidget
QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning)
{
const char *name = obs_property_name(prop);
QComboBox *combo = new QComboBox();
obs_combo_type type = obs_property_list_type(prop);
obs_combo_format format = obs_property_list_format(prop);
size_t count = obs_property_list_item_count(prop);
int idx = -1;
for (size_t i = 0; i < count; i++)
AddComboItem(combo, prop, format, i);
if (type == OBS_COMBO_TYPE_EDITABLE)
combo->setEditable(true);
string value = from_obs_data(settings, name, format);
if (format == OBS_COMBO_FORMAT_STRING &&
type == OBS_COMBO_TYPE_EDITABLE)
combo->lineEdit()->setText(QT_UTF8(value.c_str()));
else
idx = combo->findData(QT_UTF8(value.c_str()));
if (type == OBS_COMBO_TYPE_EDITABLE)
return NewWidget(prop, combo,
SIGNAL(editTextChanged(const QString &)));
if (idx != -1)
combo->setCurrentIndex(idx);
if (obs_data_has_autoselect_value(settings, name)) {
string autoselect =
from_obs_data_autoselect(settings, name, format);
int id = combo->findData(QT_UTF8(autoselect.c_str()));
if (id != -1 && id != idx) {
QString actual = combo->itemText(id);
QString selected = combo->itemText(idx);
QString combined = QTStr(
"Basic.PropertiesWindow.AutoSelectFormat");
combo->setItemText(idx,
combined.arg(selected).arg(actual));
}
}
QAbstractItemModel *model = combo->model();
warning = idx != -1 &&
model->flags(model->index(idx, 0)) == Qt::NoItemFlags;
WidgetInfo *info = new WidgetInfo(this, prop, combo);
connect(combo, SIGNAL(currentIndexChanged(int)), info,
SLOT(ControlChanged()));
children.push_back(std::move(unique_ptr<WidgetInfo>(info)));
/* trigger a settings update if the index was not found */
if (idx == -1)
info->ControlChanged();
return combo;
}
示例7: updateIconComboBox
/**
* Updates the icon combobox depending on user's selection
*/
void OptionsDialog::updateIconComboBox(int index) {
if (isRemIns == true)
return;
QString objName = QObject::sender()->objectName();
if (objName.endsWith("2")) {
p2Icon += index;
return;
}
QComboBox *cBoxR = combop2;
if (iconType == 0) {
if (index == 0) {
cBoxR->setItemIcon(0, *classicIcons[1]);
cBoxR->setItemText(0, tr("White"));
p2Icon = 0;
}
else {
cBoxR->setItemIcon(0, *classicIcons[0]);
cBoxR->setItemText(0, tr("Black"));
p2Icon = 1;
}
}
else if (iconType == 1) {
if (index == 0) {
cBoxR->setItemIcon(0, *osIcons[1]);
cBoxR->setItemText(0, tr("Debian"));
cBoxR->setItemIcon(1, *osIcons[2]);
cBoxR->setItemText(1, tr("MacOS"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[2]);
cBoxR->setItemText(1, tr("MacOS"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 0;
} else if (index == 2) {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[1]);
cBoxR->setItemText(1, tr("Debian"));
cBoxR->setItemIcon(2, *osIcons[3]);
cBoxR->setItemText(2, tr("Windows"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *osIcons[0]);
cBoxR->setItemText(0, tr("ArchLinux"));
cBoxR->setItemIcon(1, *osIcons[1]);
cBoxR->setItemText(1, tr("Debian"));
cBoxR->setItemIcon(2, *osIcons[2]);
cBoxR->setItemText(2, tr("MacOS"));
p2Icon = 0;
}
} else if (iconType == 2) {
if (index == 0) {
cBoxR->setItemIcon(0, *progIcons[1]);
cBoxR->setItemText(0, tr("Java"));
cBoxR->setItemIcon(1, *progIcons[2]);
cBoxR->setItemText(1, tr("Qt"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *progIcons[0]);
cBoxR->setItemText(0, tr("C"));
cBoxR->setItemIcon(1, *progIcons[2]);
cBoxR->setItemText(1, tr("Qt"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *progIcons[0]);
cBoxR->setItemText(0, tr("C"));
cBoxR->setItemIcon(1, *progIcons[1]);
cBoxR->setItemText(1, tr("Java"));
p2Icon = 0;
}
} else {
if (index == 0) {
cBoxR->setItemIcon(0, *teamIcons[1]);
cBoxR->setItemText(0, tr("OSFP"));
cBoxR->setItemIcon(1, *teamIcons[2]);
cBoxR->setItemText(1, tr("PAO"));
p2Icon = 1;
} else if (index == 1) {
cBoxR->setItemIcon(0, *teamIcons[0]);
cBoxR->setItemText(0, tr("AEK"));
cBoxR->setItemIcon(1, *teamIcons[2]);
cBoxR->setItemText(1, tr("PAO"));
p2Icon = 0;
} else {
cBoxR->setItemIcon(0, *teamIcons[0]);
cBoxR->setItemText(0, tr("AEK"));
cBoxR->setItemIcon(1, *teamIcons[1]);
cBoxR->setItemText(1, tr("OSFP"));
//.........这里部分代码省略.........
示例8: QDialog
QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QList< DataDefinedSymbolEntry >& entries, const QgsVectorLayer* vl, QWidget * parent, Qt::WindowFlags f )
: QDialog( parent, f )
, mVectorLayer( vl )
{
setupUi( this );
QgsFields attributeFields;
if ( mVectorLayer )
{
attributeFields = mVectorLayer->pendingFields();
}
mTableWidget->setRowCount( entries.size() );
int i = 0;
QList< DataDefinedSymbolEntry >::const_iterator entryIt = entries.constBegin();
for ( ; entryIt != entries.constEnd(); ++entryIt )
{
//check box
QCheckBox* cb = new QCheckBox( this );
cb->setChecked( !entryIt->initialValue.isEmpty() );
mTableWidget->setCellWidget( i, 0, cb );
mTableWidget->setColumnWidth( 0, cb->width() );
//property name
QTableWidgetItem* propertyItem = new QTableWidgetItem( entryIt->title );
propertyItem->setData( Qt::UserRole, entryIt->property );
mTableWidget->setItem( i, 1, propertyItem );
//attribute list
QString expressionString = entryIt->initialValue;
QComboBox* attributeComboBox = new QComboBox( this );
attributeComboBox->addItem( QString() );
for ( int j = 0; j < attributeFields.count(); ++j )
{
attributeComboBox->addItem( attributeFields.at( j ).name() );
}
int attrComboIndex = comboIndexForExpressionString( expressionString, attributeComboBox );
if ( attrComboIndex >= 0 )
{
attributeComboBox->setCurrentIndex( attrComboIndex );
}
else
{
attributeComboBox->setItemText( 0, expressionString );
}
mTableWidget->setCellWidget( i, 2, attributeComboBox );
//expression button
QPushButton* expressionButton = new QPushButton( "...", this );
QObject::connect( expressionButton, SIGNAL( clicked() ), this, SLOT( expressionButtonClicked() ) );
mTableWidget->setCellWidget( i, 3, expressionButton );
//help text
QTableWidgetItem* helpItem = new QTableWidgetItem( entryIt->helpText );
mTableWidget->setItem( i, 4, helpItem );
++i;
}
}
示例9: load
void DesignerFields::load( DesignerFields::Storage *storage )
{
QStringList keys = storage->keys();
// clear all custom page widgets
// we can't do this in the following loop, as it works on the
// custom fields of the vcard, which may not be set.
QMap<QString, QWidget *>::ConstIterator widIt;
for ( widIt = mWidgets.constBegin(); widIt != mWidgets.constEnd(); ++widIt ) {
QString value;
if ( widIt.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( widIt.value() );
wdg->setText( QString() );
} else if ( widIt.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( widIt.value() );
wdg->setValue( wdg->minimum() );
} else if ( widIt.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( widIt.value() );
wdg->setChecked( false );
} else if ( widIt.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( widIt.value() );
wdg->setDateTime( QDateTime::currentDateTime() );
} else if ( widIt.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( widIt.value() );
wdg->setDate( QDate::currentDate() );
} else if ( widIt.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( widIt.value() );
wdg->setCurrentIndex( 0 );
} else if ( widIt.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( widIt.value() );
wdg->setPlainText( QString() );
}
}
QStringList::ConstIterator it2;
for ( it2 = keys.constBegin(); it2 != keys.constEnd(); ++it2 ) {
QString value = storage->read( *it2 );
QMap<QString, QWidget *>::ConstIterator it = mWidgets.constFind( *it2 );
if ( it != mWidgets.constEnd() ) {
if ( it.value()->inherits( "QLineEdit" ) ) {
QLineEdit *wdg = static_cast<QLineEdit*>( it.value() );
wdg->setText( value );
} else if ( it.value()->inherits( "QSpinBox" ) ) {
QSpinBox *wdg = static_cast<QSpinBox*>( it.value() );
wdg->setValue( value.toInt() );
} else if ( it.value()->inherits( "QCheckBox" ) ) {
QCheckBox *wdg = static_cast<QCheckBox*>( it.value() );
wdg->setChecked( value == "true" || value == "1" );
} else if ( it.value()->inherits( "QDateTimeEdit" ) ) {
Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDateTimeWidget" ) ) {
KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( it.value() );
wdg->setDateTime( QDateTime::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "KDatePicker" ) ) {
KDatePicker *wdg = static_cast<KDatePicker*>( it.value() );
wdg->setDate( QDate::fromString( value, Qt::ISODate ) );
} else if ( it.value()->inherits( "QComboBox" ) ) {
QComboBox *wdg = static_cast<QComboBox*>( it.value() );
wdg->setItemText( wdg->currentIndex(), value );
} else if ( it.value()->inherits( "QTextEdit" ) ) {
QTextEdit *wdg = static_cast<QTextEdit*>( it.value() );
wdg->setPlainText( value );
}
}
}
}