本文整理汇总了C++中KComboBox类的典型用法代码示例。如果您正苦于以下问题:C++ KComboBox类的具体用法?C++ KComboBox怎么用?C++ KComboBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectAction
void KSelectAction_UnitTest::testSetToolTipBeforeRequestingComboBoxWidget()
{
KSelectAction selectAction("selectAction", 0);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
selectAction.setToolTip("Test");
selectAction.setEnabled(false); // also test disabling the action
QWidget parent;
QWidget* widget = selectAction.requestWidget(&parent);
QVERIFY(widget);
KComboBox* comboBox = qobject_cast<KComboBox*>(widget);
QVERIFY(comboBox);
QCOMPARE(comboBox->toolTip(), QString("Test"));
QCOMPARE(comboBox->isEnabled(), false);
}
示例2: setEditorData
void RuleDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
const QString rule = index.data(Qt::EditRole).toString();
if (rule.isEmpty())
{
return;
}
KLineEdit *ruleLineEdit = static_cast<KLineEdit*>(editor->layout()->itemAt(0)->widget());
ruleLineEdit->setText(rule.mid(rule.indexOf('+', 3) + 1));
KComboBox *matchComboBox = static_cast<KComboBox*>(editor->layout()->itemAt(1)->widget());
matchComboBox->setCurrentIndex(rule.mid(2, (rule.indexOf('+', 3) - 2)).toInt());
QCheckBox *requiredCheckBox = static_cast<QCheckBox*>(editor->layout()->itemAt(2)->widget());
requiredCheckBox->setChecked(rule.at(0) == '1');
}
示例3: selectAction
void KSelectAction_UnitTest::testRequestWidgetComboBoxModeWidgetParentSeveralActions()
{
KSelectAction selectAction("selectAction", 0);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
selectAction.addAction(new QAction("action1", &selectAction));
selectAction.addAction(new QAction("action2", &selectAction));
selectAction.addAction(new QAction("action3", &selectAction));
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget* widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
KComboBox* comboBox = qobject_cast<KComboBox*>(widget);
QVERIFY(comboBox);
QVERIFY(comboBox->isEnabled());
}
示例4: KComboBox
void
MetaQueryWidget::makeFormatComboSelection()
{
KComboBox* combo = new KComboBox( this );
combo->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
QStringList filetypes = Amarok::FileTypeSupport::possibleFileTypes();
for (int listpos=0;listpos<filetypes.size();listpos++)
{
combo->addItem(filetypes.at(listpos),listpos);
}
int index = m_fieldSelection->findData( (int)m_filter.numValue );
combo->setCurrentIndex( index == -1 ? 0 : index );
connect( combo,
SIGNAL( currentIndexChanged(int) ),
SLOT( numValueFormatChanged(int) ) );
m_valueSelection1 = combo;
}
示例5: switch
void CharactersViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
switch (index.column())
{
case 0:
case 1:
{
KLineEdit* lineEdit = static_cast<KLineEdit*>(editor);
lineEdit->setText(index.data(Qt::EditRole).toString());
break;
}
case 2:
{
KComboBox* comboBox = static_cast<KComboBox*>(editor);
comboBox->setCurrentIndex(index.data(Qt::EditRole).toInt());
break;
}
default:
QStyledItemDelegate::setEditorData(editor, index);
}
}
示例6: currentIndexChangedCB
void PrinterBehavior::currentIndexChangedCB(int index)
{
KComboBox *comboBox = qobject_cast<KComboBox*>(sender());
bool isDifferent = comboBox->property("defaultChoice").toInt() != index;
if (isDifferent != comboBox->property("different").toBool()) {
// it's different from the last time so add or remove changes
isDifferent ? m_changes++ : m_changes--;
comboBox->setProperty("different", isDifferent);
emit changed(m_changes);
}
QString attribute = comboBox->property("AttributeName").toString();
QVariant value;
// job-sheets-default has always two values
if (attribute == "job-sheets-default") {
QStringList values;
values << ui->startingBannerCB->itemData(ui->startingBannerCB->currentIndex()).toString();
values << ui->endingBannerCB->itemData(ui->endingBannerCB->currentIndex()).toString();
value = values;
} else {
value = comboBox->itemData(index).toString();
}
// store the new values
if (isDifferent) {
m_changedValues[attribute] = value;
} else {
m_changedValues.remove(attribute);
}
}
示例7: Q_UNUSED
QWidget* RuleDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option)
QWidget *editor = new QWidget(parent);
KLineEdit *ruleLineEdit = new KLineEdit(editor);
ruleLineEdit->setToolTip(i18n("Expression"));
KComboBox *matchComboBox = new KComboBox(editor);
matchComboBox->setToolTip(i18n("Match Mode"));
matchComboBox->addItem(i18n("Ignore"));
matchComboBox->addItem(i18n("Regular expression"));
matchComboBox->addItem(i18n("Partial match"));
matchComboBox->addItem(i18n("Exact match"));
QCheckBox *requiredCheckBox = new QCheckBox(editor);
requiredCheckBox->setToolTip(i18n("Required"));
QHBoxLayout *layout = new QHBoxLayout(editor);
layout->addWidget(ruleLineEdit);
layout->addWidget(matchComboBox);
layout->addWidget(requiredCheckBox);
layout->setMargin(0);
setEditorData(editor, index);
return editor;
}
示例8: setModelData
void IngredientNameDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
KComboBox *comboBox = static_cast<KComboBox*>( editor );
QString text = comboBox->currentText();
model->setData( index, text, Qt::EditRole );
if ( index.data(IngredientsEditor::IsHeaderRole).toBool() ) {
//The edited item is a header
if ( m_headerNameToIdMap.contains(text) ) {
model->setData( index, m_headerNameToIdMap.values(text).first(), IngredientsEditor::IdRole );
} else {
model->setData( index, RecipeDB::InvalidId, IngredientsEditor::IdRole );
}
} else {
//The edited item is an ingredient
if ( m_ingredientNameToIdMap.contains(text) ) {
model->setData( index, m_ingredientNameToIdMap.values(text).first(), IngredientsEditor::IdRole );
} else {
model->setData( index, RecipeDB::InvalidId, IngredientsEditor::IdRole );
}
}
}
示例9: extraArgumentsHistory
QStringList CMakeBuildDirChooser::extraArgumentsHistory() const
{
QStringList list;
KComboBox* extraArguments = m_chooserUi->extraArguments;
if (!extraArguments->currentText().isEmpty()) {
list << extraArguments->currentText();
}
for (int i = 0; i < qMin(maxExtraArgumentsInHistory, extraArguments->count()); ++i) {
if (!extraArguments->itemText(i).isEmpty() &&
(extraArguments->currentText() != extraArguments->itemText(i))) {
list << extraArguments->itemText(i);
}
}
return list;
}
示例10: KDialog
//// A dialog to load a KDE icon by its name
LoadIconDialog::LoadIconDialog(QWidget *parent)
: KDialog(parent, "loadicon_dialog", true, i18n("Load KDE Icon by Name"), Ok | Cancel, Ok, false)
{
QFrame *frame = makeMainWidget();
QGridLayout *l = new QGridLayout(frame);
// Name input
QLabel *name = new QLabel(i18n("&Name:"), frame);
l->addWidget(name, 0, 0);
name->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_nameInput = new KLineEdit("kexi", frame);
l->addWidget(m_nameInput, 0, 1);
name->setBuddy(m_nameInput);
// Choose size
QLabel *size = new QLabel(i18n("&Size:"), frame);
l->addWidget(size, 1, 0);
size->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
KComboBox *combo = new KComboBox(frame);
l->addWidget(combo, 1, 1);
size->setBuddy(combo);
QStringList list;
list << i18n("Small") << i18n("Medium") << i18n("Large") << i18n("Huge");
combo->insertStringList(list);
combo->setCurrentItem(2);
connect(combo, SIGNAL(activated(int)), this, SLOT(changeIconSize(int)));
// Icon chooser button
m_button = new KIconButton(frame);
m_button->setIcon(koIconName("calligrakexi"));
m_button->setIconSize(KIconLoader::SizeMedium);
l->addWidget(m_button, 0, 2, 2, 1);
connect(m_button, SIGNAL(iconChanged(QString)), this, SLOT(updateIconName(QString)));
connect(m_nameInput, SIGNAL(textChanged(QString)), this, SLOT(setIcon(QString)));
}
示例11: Q_UNUSED
QWidget *KOTodoPriorityDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
Q_UNUSED( option );
Q_UNUSED( index );
KComboBox *combo = new KComboBox( parent );
combo->addItem( i18nc( "@action:inmenu Unspecified priority", "unspecified" ) );
combo->addItem( i18nc( "@action:inmenu highest priority", "1 (highest)" ) );
combo->addItem( i18nc( "@action:inmenu", "2" ) );
combo->addItem( i18nc( "@action:inmenu", "3" ) );
combo->addItem( i18nc( "@action:inmenu", "4" ) );
combo->addItem( i18nc( "@action:inmenu medium priority", "5 (medium)" ) );
combo->addItem( i18nc( "@action:inmenu", "6" ) );
combo->addItem( i18nc( "@action:inmenu", "7" ) );
combo->addItem( i18nc( "@action:inmenu", "8" ) );
combo->addItem( i18nc( "@action:inmenu lowest priority", "9 (lowest)" ) );
return combo;
}
示例12: i18n
void HolidayRegionSelector::Private::initItem( QTreeWidgetItem *listItem, HolidayRegion *region )
{
m_ui.regionTreeWidget->blockSignals( true );
QString languageName = KGlobal::locale()->languageCodeToName( region->languageCode() );
listItem->setCheckState( Private::SelectColumn, Qt::Unchecked );
QString text = i18n( "<p>Select to use Holiday Region</p>" );
listItem->setToolTip( Private::SelectColumn, text );
listItem->setToolTip( Private::ComboColumn, text );
text = i18n( "<p>Select to use Holiday Region</p>" );
listItem->setToolTip( Private::SelectColumn, text );
listItem->setToolTip( Private::ComboColumn, text );
listItem->setText( Private::RegionColumn, region->name() );
QString toolTip = i18n( "<p><b>Region:</b> %1<br/>"
"<b>Language:</b> %2<br/>"
"<b>Description:</b> %3</p>",
region->name(), languageName, region->description() );
listItem->setToolTip( Private::RegionColumn, toolTip );
listItem->setData( Private::RegionColumn, Qt::UserRole, region->regionCode() );
listItem->setText( Private::LanguageColumn, languageName );
listItem->setData( Private::LanguageColumn, Qt::UserRole, region->languageCode() );
listItem->setText( Private::DescriptionColumn, region->description() );
listItem->setToolTip( Private::DescriptionColumn, region->description() );
KComboBox *combo = new KComboBox();
combo->setAutoFillBackground( true );
QString comboText = i18n( "<p>You can choose to display the Holiday Region for information only, "
"or to use the Holiday Region when displaying or calculating days off "
"such as Public Holidays. If you choose to use the Holiday Region for "
"Days Off, then only those Holiday Events marked in the Holiday Region "
"as Days Off will be used for non-work days, Holiday Events that are "
"not marked in the Holiday Region as Days Off will continue to be "
"work days.</p>" );
combo->setToolTip( comboText );
comboText = i18nc( "Combobox label, Holiday Region not used", "Not Used" );
combo->addItem( comboText, QVariant( NotUsed ) );
comboText = i18nc( "Combobox label, use Holiday Region for information only", "Information" );
combo->addItem( comboText, QVariant( UseInformationOnly ) );
comboText = i18nc( "Combobox label, use Holiday Region for days off", "Days Off" );
combo->addItem( comboText, QVariant( UseDaysOff ) );
combo->setCurrentIndex( 0 );
listItem->setData( Private::ComboColumn, Qt::UserRole, NotUsed );
m_ui.regionTreeWidget->setItemWidget( listItem, ComboColumn, combo );
connect( combo, SIGNAL(currentIndexChanged(int)),
q, SLOT(itemChanged(int)) );
m_ui.regionTreeWidget->blockSignals( false );
}
示例13: KComboBox
QWidget * IngredientNameDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */,
const QModelIndex & index ) const
{
//Set up the combo box
KComboBox * editor = new KComboBox( parent );
editor->setAutoFillBackground( true );
editor->setEditable( true );
editor->setCompletionMode( KGlobalSettings::CompletionPopup );
//Set the models and the completion objects
if ( !index.data(IngredientsEditor::IsHeaderRole).toBool() ) {
editor->setModel( m_database->allIngredientsModels()->ingredientNameModel() );
editor->setCompletionObject(
m_database->allIngredientsModels()->ingredientNameCompletion() );
} else {
editor->setModel( m_database->allIngHeadersModels()->ingHeaderNameModel() );
editor->setCompletionObject(
m_database->allIngHeadersModels()->ingHeaderNameCompletion() );
}
return editor;
}
示例14: setupGUI
void setupGUI()
{
QBoxLayout *layout = new QVBoxLayout(p);
tabWidget = new QTabWidget(p);
layout->addWidget(tabWidget);
QWidget *container = new QWidget(tabWidget);
tabWidget->addTab(container, QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Library"));
connect(tabWidget, &QTabWidget::currentChanged, p, &ZoteroBrowser::tabChanged);
QBoxLayout *containerLayout = new QVBoxLayout(container);
/// Personal or Group Library
QGridLayout *gridLayout = new QGridLayout();
containerLayout->addLayout(gridLayout);
gridLayout->setMargin(0);
gridLayout->setColumnMinimumWidth(0, 16); // TODO determine size of a radio button
radioPersonalLibrary = new QRadioButton(i18n("Personal library"), container);
gridLayout->addWidget(radioPersonalLibrary, 0, 0, 1, 2);
radioGroupLibrary = new QRadioButton(i18n("Group library"), container);
gridLayout->addWidget(radioGroupLibrary, 1, 0, 1, 2);
comboBoxGroupList = new KComboBox(false, container);
gridLayout->addWidget(comboBoxGroupList, 2, 1, 1, 1);
QSizePolicy sizePolicy = comboBoxGroupList->sizePolicy();
sizePolicy.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
comboBoxGroupList->setSizePolicy(sizePolicy);
radioPersonalLibrary->setChecked(true);
comboBoxGroupList->setEnabled(false);
comboBoxGroupList->addItem(i18n("No groups available"));
connect(radioGroupLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
connect(radioPersonalLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
connect(comboBoxGroupList, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), p, &ZoteroBrowser::groupListChanged);
containerLayout->addStretch(10);
/// Credentials
QFormLayout *containerForm = new QFormLayout();
containerLayout->addLayout(containerForm, 1);
containerForm->setMargin(0);
lineEditNumericUserId = new KLineEdit(container);
lineEditNumericUserId->setSizePolicy(sizePolicy);
lineEditNumericUserId->setReadOnly(true);
containerForm->addRow(i18n("Numeric user id:"), lineEditNumericUserId);
connect(lineEditNumericUserId, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);
lineEditApiKey = new KLineEdit(container);
lineEditApiKey->setSizePolicy(sizePolicy);
lineEditApiKey->setReadOnly(true);
containerForm->addRow(i18n("API key:"), lineEditApiKey);
connect(lineEditApiKey, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);
QBoxLayout *containerButtonLayout = new QHBoxLayout();
containerLayout->addLayout(containerButtonLayout, 0);
containerButtonLayout->setMargin(0);
QPushButton *buttonGetOAuthCredentials = new QPushButton(QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Get New Credentials"), container);
containerButtonLayout->addWidget(buttonGetOAuthCredentials, 0);
connect(buttonGetOAuthCredentials, &QPushButton::clicked, p, &ZoteroBrowser::getOAuthCredentials);
containerButtonLayout->addStretch(1);
/// Collection browser
collectionBrowser = new QTreeView(tabWidget);
tabWidget->addTab(collectionBrowser, QIcon::fromTheme(QStringLiteral("folder-yellow")), i18n("Collections"));
collectionBrowser->setHeaderHidden(true);
collectionBrowser->setExpandsOnDoubleClick(false);
connect(collectionBrowser, &QTreeView::doubleClicked, p, &ZoteroBrowser::collectionDoubleClicked);
/// Tag browser
tagBrowser = new QListView(tabWidget);
tabWidget->addTab(tagBrowser, QIcon::fromTheme(QStringLiteral("mail-tagged")), i18n("Tags"));
connect(tagBrowser, &QListView::doubleClicked, p, &ZoteroBrowser::tagDoubleClicked);
}
示例15: kDebug
void ConditionalDialog::init(KCConditional const & tmp, int numCondition)
{
kDebug() << "Adding" << numCondition;
KComboBox * cb = 0;
KComboBox * sb = 0;
KLineEdit * kl1 = 0;
KLineEdit * kl2 = 0;
QString value;
KCMap *const map = m_selection->activeSheet()->map();
KCValueConverter *const converter = map->converter();
switch (numCondition) {
case 0:
cb = m_dlg->m_condition_1;
sb = m_dlg->m_style_1;
kl1 = m_dlg->m_firstValue_1;
kl2 = m_dlg->m_secondValue_1;
break;
case 1:
cb = m_dlg->m_condition_2;
sb = m_dlg->m_style_2;
kl1 = m_dlg->m_firstValue_2;
kl2 = m_dlg->m_secondValue_2;
break;
case 2:
cb = m_dlg->m_condition_3;
sb = m_dlg->m_style_3;
kl1 = m_dlg->m_firstValue_3;
kl2 = m_dlg->m_secondValue_3;
break;
default:
return;
}
if (!tmp.styleName.isEmpty()) {
sb->setCurrentIndex(sb->findText(tmp.styleName));
sb->setEnabled(true);
}
switch (tmp.cond) {
case KCConditional::None :
case KCConditional::IsTrueFormula: // was unhandled
break;
case KCConditional::Equal :
cb->setCurrentIndex(1);
break;
case KCConditional::Superior :
cb->setCurrentIndex(2);
break;
case KCConditional::Inferior :
cb->setCurrentIndex(3);
break;
case KCConditional::SuperiorEqual :
cb->setCurrentIndex(4);
break;
case KCConditional::InferiorEqual :
cb->setCurrentIndex(5);
break;
case KCConditional::Between :
cb->setCurrentIndex(6);
kl2->setText(converter->asString(tmp.value2).asString());
break;
case KCConditional::Different :
cb->setCurrentIndex(7);
kl2->setText(converter->asString(tmp.value2).asString());
break;
case KCConditional::DifferentTo :
cb->setCurrentIndex(8);
break;
}
if (tmp.cond != KCConditional::None) {
kl1->setEnabled(true);
kl1->setText(converter->asString(tmp.value1).asString());
}
}