本文整理汇总了C++中QComboBox::model方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::model方法的具体用法?C++ QComboBox::model怎么用?C++ QComboBox::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QComboBox
QMultiMap<int, IOptionsDialogWidget *> StatusIcons::optionsDialogWidgets(const QString &ANodeId, QWidget *AParent)
{
QMultiMap<int, IOptionsDialogWidget *> widgets;
if (FOptionsManager!=NULL && ANodeId==OPN_APPEARANCE)
{
QComboBox *cmbStatusIcons = new QComboBox(AParent);
cmbStatusIcons->setItemDelegate(new IconsetDelegate(cmbStatusIcons));
int index = 0;
for (QMap<QString, IconStorage *>::const_iterator it=FStorages.constBegin(); it!=FStorages.constEnd(); ++it)
{
QString name = it.value()->storageProperty(FILE_STORAGE_NAME,it.key());
cmbStatusIcons->addItem(it.value()->getIcon(SIK_ONLINE),name,it.key());
cmbStatusIcons->setItemData(index,it.value()->storage(),IconsetDelegate::IDR_STORAGE);
cmbStatusIcons->setItemData(index,it.value()->subStorage(),IconsetDelegate::IDR_SUBSTORAGE);
cmbStatusIcons->setItemData(index,true,IconsetDelegate::IDR_HIDE_STORAGE_NAME);
index++;
}
cmbStatusIcons->model()->sort(0);
widgets.insertMulti(OHO_APPEARANCE_ROSTER, FOptionsManager->newOptionsDialogHeader(tr("Contacts list"),AParent));
widgets.insertMulti(OWO_APPEARANCE_STATUSICONS, FOptionsManager->newOptionsDialogWidget(Options::node(OPV_STATUSICONS_DEFAULT),tr("Status icons:"),cmbStatusIcons,AParent));
}
return widgets;
}
示例2: populateGroupCelestialBodyList
void AstroCalcDialog::populateGroupCelestialBodyList()
{
Q_ASSERT(ui->object2ComboBox);
QComboBox* groups = ui->object2ComboBox;
groups->blockSignals(true);
int index = groups->currentIndex();
QVariant selectedGroupId = groups->itemData(index);
groups->clear();
groups->addItem(q_("Solar system"), "0");
groups->addItem(q_("Planets"), "1");
groups->addItem(q_("Asteroids"), "2");
groups->addItem(q_("Plutinos"), "3");
groups->addItem(q_("Comets"), "4");
groups->addItem(q_("Dwarf planets"), "5");
groups->addItem(q_("Cubewanos"), "6");
groups->addItem(q_("Scattered disc objects"), "7");
groups->addItem(q_("Oort cloud objects"), "8");
index = groups->findData(selectedGroupId, Qt::UserRole, Qt::MatchCaseSensitive);
if (index<0)
index = groups->findData("1", Qt::UserRole, Qt::MatchCaseSensitive);
groups->setCurrentIndex(index);
groups->model()->sort(0);
groups->blockSignals(false);
}
示例3: populateMajorPlanetList
void AstroCalcDialog::populateMajorPlanetList()
{
Q_ASSERT(ui->object1ComboBox); // object 1 is always major planet
QComboBox* majorPlanet = ui->object1ComboBox;
QList<PlanetP> planets = solarSystem->getAllPlanets();
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
//Save the current selection to be restored later
majorPlanet->blockSignals(true);
int index = majorPlanet->currentIndex();
QVariant selectedPlanetId = majorPlanet->itemData(index);
majorPlanet->clear();
//For each planet, display the localized name and store the original as user
//data. Unfortunately, there's no other way to do this than with a cycle.
foreach(const PlanetP& planet, planets)
{
if (planet->getPlanetType()==Planet::isPlanet && planet->getEnglishName()!=core->getCurrentPlanet()->getEnglishName())
majorPlanet->addItem(trans.qtranslate(planet->getNameI18n()), planet->getEnglishName());
}
//Restore the selection
index = majorPlanet->findData(selectedPlanetId, Qt::UserRole, Qt::MatchCaseSensitive);
if (index<0)
index = majorPlanet->findData("Mercury", Qt::UserRole, Qt::MatchCaseSensitive);;
majorPlanet->setCurrentIndex(index);
majorPlanet->model()->sort(0);
majorPlanet->blockSignals(false);
}
示例4: populateCelestialBodyList
void AstroCalcDialog::populateCelestialBodyList()
{
Q_ASSERT(ui->celestialBodyComboBox);
QComboBox* planets = ui->celestialBodyComboBox;
QStringList planetNames(solarSystem->getAllPlanetEnglishNames());
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
//Save the current selection to be restored later
planets->blockSignals(true);
int index = planets->currentIndex();
QVariant selectedPlanetId = planets->itemData(index);
planets->clear();
//For each planet, display the localized name and store the original as user
//data. Unfortunately, there's no other way to do this than with a cycle.
foreach(const QString& name, planetNames)
{
if (name!="Solar System Observer" && name!="Sun" && name!=core->getCurrentPlanet()->getEnglishName())
planets->addItem(trans.qtranslate(name), name);
}
//Restore the selection
index = planets->findData(selectedPlanetId, Qt::UserRole, Qt::MatchCaseSensitive);
if (index<0)
index = planets->findData("Moon", Qt::UserRole, Qt::MatchCaseSensitive);;
planets->setCurrentIndex(index);
planets->model()->sort(0);
planets->blockSignals(false);
}
示例5: QComboBox
QWidget *ZoomAction::createWidget(QWidget *parent)
{
QComboBox *comboBox = new QComboBox(parent);
if (m_comboBoxModel.isNull()) {
m_comboBoxModel = comboBox->model();
comboBox->addItem("10 %", 0.1);
comboBox->addItem("25 %", 0.25);
comboBox->addItem("50 %", 0.5);
comboBox->addItem("100 %", 1.0);
comboBox->addItem("200 %", 2.0);
comboBox->addItem("400 %", 4.0);
comboBox->addItem("800 %", 8.0);
comboBox->addItem("1600 %", 16.0);
} else {
comboBox->setModel(m_comboBoxModel.data());
}
comboBox->setCurrentIndex(3);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitZoomLevelChanged(int)));
connect(this, SIGNAL(indexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
comboBox->setProperty("hideborder", true);
return comboBox;
}
示例6: onEasingCurveChanged
void FrameInfoWidget::onEasingCurveChanged(int iIndex)
{
if (iIndex == QEasingCurve::Custom)
{
QComboBox* pCombo = qobject_cast<QComboBox*>(sender());
if (pCombo)
{
EasingCurveModel* pModel = (EasingCurveModel*)pCombo->model();
SplineEditor* pEditor = pModel->GetCustomEditor();
if (pEditor && !pEditor->isVisible())
pEditor->show();
}
}
}
示例7: setModelData
// Запись данных в модель
void ComboBoxFileldDelegate::setModelData( QWidget * editor, QAbstractItemModel * model, const QModelIndex & index )const {
QComboBox* pRes = dynamic_cast<QComboBox*>(editor);
if (pRes) {
if (index.column()>2){
QString pole = index.model()->data(index.sibling(index.row(),0)).toString();
int j;
for(int i=0;i<fieldName.count();i++){
QString s = this->model->headerData( fieldName.at(i) , Qt::Horizontal).toString();
s.replace("\n"," ");
if (s==pole){
j=fieldName.at(i);
break;
}
}
if (this->model->data(this->model->index(0,j), Qt::EditRole).type() == QVariant::Bool){
model->setData(index,pRes->currentIndex(),Qt::EditRole);
return;
}
QString str = pRes->model()->data(pRes->model()->index(pRes->currentIndex(),0)).toString();
model->setData(index,str,Qt::EditRole);
}else{
QString str = pRes->currentText();
model->setData(index,str,Qt::EditRole);
if (index.column()==0)
model->setData(index.sibling(index.row(),3),"",Qt::EditRole);
}
}else{
QItemDelegate::setModelData(editor,model,index);
}
};
示例8: 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)));
}
示例9: addbookmarkdialog
void tst_AddBookmarkDialog::addbookmarkdialog()
{
QFETCH(QString, url);
QFETCH(QString, title);
QFETCH(QDialogButtonBox::StandardButton, button);
QFETCH(int, menuCount);
QFETCH(int, toolbarCount);
QFETCH(int, select);
BookmarksManager *manager = BrowserApplication::bookmarksManager();
qRegisterMetaType<BookmarkNode *>("BookmarkNode *");
QSignalSpy spy(manager, SIGNAL(entryAdded(BookmarkNode *)));
BookmarkNode *menu = manager->menu();
BookmarkNode *toolbar = manager->toolbar();
QCOMPARE(menu->children().count(), 0);
QCOMPARE(toolbar->children().count(), 0);
SubAddBookmarkDialog dialog(0, manager);
dialog.setUrl(url);
dialog.setTitle(title);
QComboBox *combobox = dialog.findChild<QComboBox*>();
QVERIFY(combobox);
if (select != -1) {
combobox->setCurrentIndex(select);
combobox->view()->setCurrentIndex(combobox->model()->index(select, 0));
}
QDialogButtonBox *buttonBox = dialog.findChild<QDialogButtonBox*>();
QVERIFY(buttonBox);
QPushButton *pushButton = buttonBox->button(button);
pushButton->click();
QCOMPARE(spy.count(), menuCount + toolbarCount);
QCOMPARE(menu->children().count(), menuCount);
QCOMPARE(toolbar->children().count(), toolbarCount);
BookmarkNode *node = 0;
if (menuCount == 1) node = menu->children()[0];
if (toolbarCount == 1) node = toolbar->children()[0];
if (node) {
QCOMPARE(node->title, title);
QCOMPARE(node->url, url);
}
}
示例10: populateSimbadServerList
void SearchDialog::populateSimbadServerList()
{
Q_ASSERT(ui->serverListComboBox);
QComboBox* servers = ui->serverListComboBox;
//Save the current selection to be restored later
servers->blockSignals(true);
int index = servers->currentIndex();
QVariant selectedUrl = servers->itemData(index);
servers->clear();
//For each server, display the localized description and store the URL as user data.
servers->addItem(q_("University of Strasbourg (France)"), DEF_SIMBAD_URL);
servers->addItem(q_("Harvard University (USA)"), "http://simbad.harvard.edu/");
//Restore the selection
index = servers->findData(selectedUrl, Qt::UserRole, Qt::MatchCaseSensitive);
servers->setCurrentIndex(index);
servers->model()->sort(0);
servers->blockSignals(false);
}
示例11: updateSelections
void MainWindow::updateSelections() {
QStringList selectedDevices;
for(int i=0; i<ui->tableWidget->rowCount(); i++) {
QComboBox* rowCombo = (QComboBox*)ui->tableWidget->cellWidget(i, 0);
selectedDevices << rowCombo->currentData().toString();
}
for(int i=0; i<ui->tableWidget->rowCount(); i++) {
QComboBox* rowCombo = (QComboBox*)ui->tableWidget->cellWidget(i, 0);
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(rowCombo->model());
for(int r=0; r<rowCombo->count(); r++) {
if(r == rowCombo->currentIndex())
continue;
QVariant value;
QStandardItem* item = model->item(r);
if(!selectedDevices.contains(item->data(Qt::UserRole).toString()))
value = 1 | 32;
else
value = 0;
item->setData(value, Qt::UserRole - 1);
}
}
}
示例12: QComboBox
QWidget *ZoomAction::createWidget(QWidget *parent)
{
QComboBox *comboBox = new QComboBox(parent);
if (m_comboBoxModel.isNull()) {
m_comboBoxModel = comboBox->model();
comboBox->addItem(QLatin1String("6.25 %"), 0.0625);
comboBox->addItem(QLatin1String("12.5 %"), 0.125);
comboBox->addItem(QLatin1String("25 %"), 0.25);
comboBox->addItem(QLatin1String("33 %"), 0.33);
comboBox->addItem(QLatin1String("50 %"), 0.5);
comboBox->addItem(QLatin1String("66 %"), 0.66);
comboBox->addItem(QLatin1String("75 %"), 0.75);
comboBox->addItem(QLatin1String("90 %"), 0.90);
comboBox->addItem(QLatin1String("100 %"), 1.0);
comboBox->addItem(QLatin1String("125 %"), 1.25);
comboBox->addItem(QLatin1String("150 %"), 1.5);
comboBox->addItem(QLatin1String("175 %"), 1.75);
comboBox->addItem(QLatin1String("200 %"), 2.0);
comboBox->addItem(QLatin1String("300 %"), 3.0);
comboBox->addItem(QLatin1String("400 %"), 4.0);
comboBox->addItem(QLatin1String("600 %"), 6.0);
comboBox->addItem(QLatin1String("800 %"), 8.0);
comboBox->addItem(QLatin1String("1000 %"), 10.0);
comboBox->addItem(QLatin1String("1600 %"), 16.0);
} else {
comboBox->setModel(m_comboBoxModel.data());
}
comboBox->setCurrentIndex(8);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitZoomLevelChanged(int)));
connect(this, SIGNAL(indexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
comboBox->setProperty("hideborder", true);
return comboBox;
}
示例13: QDialog
lcQFindDialog::lcQFindDialog(QWidget *parent, void *data) :
QDialog(parent),
ui(new Ui::lcQFindDialog)
{
ui->setupUi(this);
QComboBox *parts = ui->ID;
parts->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
parts->setMinimumContentsLength(1);
lcPiecesLibrary* library = lcGetPiecesLibrary();
for (int partIdx = 0; partIdx < library->mPieces.GetSize(); partIdx++)
parts->addItem(library->mPieces[partIdx]->m_strDescription, qVariantFromValue((void*)library->mPieces[partIdx]));
parts->model()->sort(0);
options = (lcSearchOptions*)data;
ui->findColor->setChecked(options->MatchColor);
ui->color->setCurrentColor(options->ColorIndex);
ui->findID->setChecked(options->MatchInfo);
parts->setCurrentIndex(parts->findData(qVariantFromValue((void*)options->Info)));
ui->findName->setChecked(options->MatchName);
ui->name->setText(options->Name);
}
示例14: on_addStream_clicked
void MainWindow::on_addStream_clicked()
{
int rowID = ui->tableWidget->rowCount();
ui->tableWidget->insertRow(rowID);
QComboBox* sinkSelection = new QComboBox();
QPushButton* removeStream = new QPushButton("Remove");
if(rowID == 0)
removeStream->setEnabled(false);
else if(rowID == 1)
ui->tableWidget->cellWidget(0, 1)->setEnabled(true);
connect(removeStream, &QPushButton::clicked, [=] () {
for(int i=0; i<ui->tableWidget->rowCount(); i++) {
if(ui->tableWidget->cellWidget(i, 0) == sinkSelection) {
ui->tableWidget->removeRow(i);
break;
}
}
ui->addStream->setEnabled(true);
if(ui->tableWidget->rowCount() == 1) {
ui->tableWidget->cellWidget(0, 1)->setEnabled(false);
QComboBox* rowCombo = (QComboBox*)ui->tableWidget->cellWidget(0, 0);
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(rowCombo->model());
for(int r=0; r<rowCombo->count(); r++) {
if(r == rowCombo->currentIndex())
continue;
QStandardItem* item = model->item(r);
item->setData(1 | 32, Qt::UserRole - 1);
}
} else
updateSelections();
});
int defaultItem = 0;
bool lastWasDisabled = true;
QHashIterator<QString, QString> it(devices);
while(it.hasNext()) {
it.next();
bool disabled = false;
sinkSelection->addItem(it.value(), it.key());
for(int i=0; i<rowID; i++) {
QComboBox* rowCombo = (QComboBox*)ui->tableWidget->cellWidget(i, 0);
if(rowCombo->currentData() == it.key()) {
disabled = true;
break;
}
}
if(lastWasDisabled) {
if(disabled)
defaultItem ++;
else
lastWasDisabled = false;
}
}
if(defaultItem > 0)
sinkSelection->setCurrentIndex(defaultItem);
if(rowID == devices.size()-1)
ui->addStream->setEnabled(false);
ui->tableWidget->setCellWidget(rowID, 0, sinkSelection);
ui->tableWidget->setCellWidget(rowID, 1, removeStream);
updateSelections();
connect(sinkSelection, &QComboBox::currentTextChanged, [=] (QString) {
updateSelections();
});
}
示例15: 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;
}