本文整理汇总了C++中QComboBox::itemData方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::itemData方法的具体用法?C++ QComboBox::itemData怎么用?C++ QComboBox::itemData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::itemData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formLoginClicked
// Writes the user input from the form into the oc_auth_form structs we got from
// libopenconnect, and wakes the worker thread up to try to log in and obtain a
// cookie with this data
void OpenconnectAuthWidget::formLoginClicked()
{
Q_D(OpenconnectAuthWidget);
const int lastIndex = d->ui.loginBoxLayout->count() - 1;
QLayout *layout = d->ui.loginBoxLayout->itemAt(d->passwordFormIndex)->layout();
struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();
for (int i = 0; i < layout->count(); i++) {
QLayoutItem *item = layout->itemAt(i);
QWidget *widget = item->widget();
if (widget && widget->property("openconnect_opt").isValid()) {
struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
QLineEdit *le = qobject_cast<QLineEdit*>(widget);
QByteArray text = le->text().toUtf8();
openconnect_set_option_value(opt, text.data());
if (opt->type == OC_FORM_OPT_TEXT) {
d->secrets.insert(key, le->text());
} else {
d->tmpSecrets.insert(key, le->text());
}
} else if (opt->type == OC_FORM_OPT_SELECT) {
QComboBox *cbo = qobject_cast<QComboBox*>(widget);
QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
openconnect_set_option_value(opt, text.data());
d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
}
}
}
deleteAllFromLayout(d->ui.loginBoxLayout);
d->workerWaiting.wakeAll();
}
示例2: setValue
void InspectorBase::setValue(const InspectorItem& ii, QVariant val)
{
QWidget* w = ii.w;
P_ID id = ii.t;
P_TYPE t = propertyType(id);
if (t == T_POINT)
val = val.toDouble() / inspector->element()->score()->spatium();
if (qobject_cast<QDoubleSpinBox*>(w))
static_cast<QDoubleSpinBox*>(w)->setValue(val.toDouble());
else if (qobject_cast<QSpinBox*>(w))
static_cast<QSpinBox*>(w)->setValue(val.toInt());
else if (qobject_cast<QComboBox*>(w)) {
int ival = val.toInt();
QComboBox* cb = qobject_cast<QComboBox*>(w);
if (cb->itemData(0).isValid()) {
for (int i = 0; i < cb->count(); ++i) {
if (cb->itemData(i).toInt() == ival) {
ival = i;
break;
}
}
}
cb->setCurrentIndex(ival);
}
else if (qobject_cast<QCheckBox*>(w))
static_cast<QCheckBox*>(w)->setChecked(val.toBool());
else if (qobject_cast<QLineEdit*>(w))
static_cast<QLineEdit*>(w)->setText(val.toString());
else if (qobject_cast<Awl::ColorLabel*>(w))
static_cast<Awl::ColorLabel*>(w)->setColor(val.value<QColor>());
else
qFatal("not supported widget %s", w->metaObject()->className());
}
示例3: getValue
QVariant InspectorBase::getValue(const InspectorItem& ii) const
{
QWidget* w = ii.w;
QVariant v;
if (qobject_cast<QDoubleSpinBox*>(w))
v = w->property("value");
else if (qobject_cast<QSpinBox*>(w))
v = w->property("value");
else if (qobject_cast<QComboBox*>(w)) {
QComboBox* cb = qobject_cast<QComboBox*>(w);
int val = cb->currentIndex();
if (cb->itemData(val).isValid())
val = cb->itemData(val).toInt();
v = val;
}
else if (qobject_cast<QCheckBox*>(w))
v = w->property("checked");
else if (qobject_cast<QLineEdit*>(w))
v = w->property("text");
else if (qobject_cast<Awl::ColorLabel*>(w))
v = static_cast<Awl::ColorLabel*>(w)->color();
else
qFatal("not supported widget %s", w->metaObject()->className());
P_ID id = ii.t;
P_TYPE t = propertyType(id);
if (t == T_POINT)
v = v.toDouble() * inspector->element()->score()->spatium();
return v;
}
示例4: setModelData
void UDPTreeDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, QModelIndex const & index) const
{//this function needs to store data to the object model AND back to the database.
if(!editor)
return;
QString protocolName = model->data(index.sibling(index.row(),0), Qt::DisplayRole).toString();
switch(index.column())
{
case 0: //lineEdit
{
QLineEdit * line = static_cast<QLineEdit*>(editor);
fw->setName( protocolName.toStdString(), line->text().toStdString());
applyToAllName(line->text(), model, index);
return;
}
case 1: //comboBox
{
QComboBox * combo = static_cast<QComboBox*>(editor);
int curindex = combo->itemData(combo->currentIndex()).toInt();
QString text= combo->currentText();
fw->setType(protocolName.toStdString(), curindex, index.row());
if(curindex == IPPROTO_TCP)
dynamic_cast<QStandardItemModel*>(model)->itemFromIndex(index.sibling(index.row(), 3))->setFlags(0);
else
dynamic_cast<QStandardItemModel*>(model)->itemFromIndex(index.sibling(index.row(), 3))->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
model->setData(index, curindex, Qt::EditRole);
model->setData(index, text, Qt::DisplayRole);
//set the firewall data here as well
return;
}
case 2: //rangeEditWidget
{
rangeEdit* range = static_cast<rangeEdit*>(editor);
int i, j;
range->value(i,j);
fw->setStartPort(protocolName.toStdString(), i, index.row());
fw->setEndPort(protocolName.toStdString(), j, index.row());
QString rangeString = fw->getRangeStrings(protocolName.toStdString())[index.row()].c_str();
model->setData(index, rangeString, Qt::EditRole);//get the value from the protocol
return;
}
case 3:
{
QComboBox * combo = static_cast<QComboBox*>(editor);
int curindex = combo->itemData(combo->currentIndex()).toInt();
QString text= combo->currentText();
fw->setBidirectional(protocolName.toStdString(), curindex, index.row());
model->setData(index, curindex, Qt::EditRole);
model->setData(index, text, Qt::DisplayRole);
return;
}
default:
{
}
}
return;
}
示例5: switch
void koregui::FrameBufferEditor::applySettings(void) {
if(!_currentbuffer) return;
uint colortarget = 0;
for(int i = 0; i < ui.tableWidget->rowCount(); i++) {
kore::STextureProperties props;
props.targetType = GL_TEXTURE_2D;
QHBoxLayout* hlay =
static_cast<QHBoxLayout*>(ui.tableWidget->cellWidget(i, 1)->layout());
QLineEdit* res = static_cast<QLineEdit*>(hlay->itemAt(0)->widget());
uint resx = res->text().toUInt();
res = static_cast<QLineEdit*>(hlay->itemAt(2)->widget());
uint resy = res->text().toUInt();
QCheckBox* cb = static_cast<QCheckBox*>(hlay->itemAt(3)->widget());
bool autores = (cb->isChecked())?true:false;
props.width = resx;
props.height = resy;
QComboBox* cbox =
static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 2));
props.format = cbox->itemData(cbox->currentIndex()).toUInt();
cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 3));
props.internalFormat = cbox->itemData(cbox->currentIndex()).toUInt();
cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 4));
props.pixelType = cbox->itemData(cbox->currentIndex()).toUInt();
cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 0));
GLuint target = cbox->itemData(cbox->currentIndex()).toUInt();
switch(target) {
case GL_COLOR_ATTACHMENT0:
_currentbuffer->addTextureAttachment(props,
"Color",
GL_COLOR_ATTACHMENT0 + colortarget);
colortarget++;
break;
case GL_DEPTH_ATTACHMENT:
_currentbuffer->addTextureAttachment(props,
"Depth",
GL_DEPTH_ATTACHMENT);
break;
case GL_STENCIL_ATTACHMENT:
_currentbuffer->addTextureAttachment(props,
"Stencil",
GL_STENCIL_ATTACHMENT);
break;
default:
// ERROR
break;
}
}
_currentitem->setFrameBuffer(_currentbuffer);
refresh();
}
示例6: setValue
void InspectorBase::setValue(const InspectorItem& ii, QVariant val)
{
QWidget* w = ii.w;
P_ID id = ii.t;
switch (propertyType(id)) {
case P_TYPE::POINT:
case P_TYPE::SP_REAL:
val = val.toDouble() / inspector->element()->score()->spatium();
break;
case P_TYPE::TEMPO:
val = val.toDouble() * 60.0;
break;
case P_TYPE::POINT_MM:
val = val.toDouble() / DPMM;
case P_TYPE::SIZE_MM:
val = val.toDouble() / DPMM;
break;
case P_TYPE::DIRECTION:
val = int(val.value<Direction>());
break;
default:
break;
}
if (qobject_cast<QDoubleSpinBox*>(w))
static_cast<QDoubleSpinBox*>(w)->setValue(val.toDouble());
else if (qobject_cast<QSpinBox*>(w))
static_cast<QSpinBox*>(w)->setValue(val.toInt());
else if (qobject_cast<QComboBox*>(w)) {
int ival = val.toInt();
QComboBox* cb = qobject_cast<QComboBox*>(w);
if (cb->itemData(0).isValid()) {
for (int i = 0; i < cb->count(); ++i) {
if (cb->itemData(i).toInt() == ival) {
ival = i;
break;
}
}
}
cb->setCurrentIndex(ival);
}
else if (qobject_cast<QCheckBox*>(w))
static_cast<QCheckBox*>(w)->setChecked(val.toBool());
else if (qobject_cast<QLineEdit*>(w))
static_cast<QLineEdit*>(w)->setText(val.toString());
else if (qobject_cast<Awl::ColorLabel*>(w))
static_cast<Awl::ColorLabel*>(w)->setColor(val.value<QColor>());
else
qFatal("not supported widget %s", w->metaObject()->className());
}
示例7: getValue
QVariant InspectorBase::getValue(const InspectorItem& ii) const
{
QWidget* w = ii.w;
QVariant v;
if (qobject_cast<QDoubleSpinBox*>(w))
v = w->property("value");
else if (qobject_cast<QSpinBox*>(w))
v = w->property("value");
else if (qobject_cast<QComboBox*>(w)) {
QComboBox* cb = qobject_cast<QComboBox*>(w);
int val = cb->currentIndex();
if (cb->itemData(val).isValid())
val = cb->itemData(val).toInt();
v = val;
}
else if (qobject_cast<QCheckBox*>(w))
v = w->property("checked");
else if (qobject_cast<QLineEdit*>(w))
v = w->property("text");
else if (qobject_cast<Awl::ColorLabel*>(w))
v = static_cast<Awl::ColorLabel*>(w)->color();
else
qFatal("not supported widget %s", w->metaObject()->className());
switch (propertyType(ii.t)) {
case P_TYPE::POINT:
case P_TYPE::SP_REAL:
v = v.toDouble() * inspector->element()->score()->spatium();
break;
case P_TYPE::TEMPO:
v = v.toDouble() / 60.0;
break;
case P_TYPE::POINT_MM:
case P_TYPE::SIZE_MM:
v = v.toDouble() * DPMM;
break;
case P_TYPE::BARLINE_TYPE:
v = QVariant::fromValue(BarLineType(v.toInt()));
break;
case P_TYPE::DIRECTION:
v = QVariant::fromValue(Direction(v.toInt()));
break;
default:
break;
}
return v;
}
示例8: redo
void HistoryElementRemoveWarp::redo()
{
if(!m_scene)
return;
LvlScene* lvlScene;
if(!(lvlScene = qobject_cast<LvlScene*>(m_scene)))
return;
lvlScene->doorPointsSync( m_removedDoor.meta.array_id, true);
for(int i=0;i<lvlScene->m_data->doors.size();i++)
{
if(lvlScene->m_data->doors[i].meta.array_id==m_removedDoor.meta.array_id)
{
lvlScene->m_data->doors.removeAt(i);
break;
}
}
QComboBox* warplist = MainWinConnect::pMainWin->dock_LvlWarpProps->getWarpList();
for(int i = 0; i < warplist->count(); i++){
if((unsigned int)warplist->itemData(i).toInt() == m_removedDoor.meta.array_id){
warplist->removeItem(i);
break;
}
}
if(warplist->count()<=0) MainWinConnect::pMainWin->dock_LvlWarpProps->setWarpRemoveButtonEnabled(false);
MainWinConnect::pMainWin->dock_LvlWarpProps->setDoorData(-2);
}
示例9: collectExtraInfo
bool Pad::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
if (prop.compare("shape", Qt::CaseInsensitive) == 0) {
returnWidget = setUpDimEntry(false, false, false, returnWidget);
returnWidget->setEnabled(swappingEnabled);
returnProp = tr("shape");
return true;
}
if (!copperBlocker()) {
if (prop.compare("connect to", Qt::CaseInsensitive) == 0) {
QComboBox * comboBox = new QComboBox();
comboBox->setObjectName("infoViewComboBox");
comboBox->setEditable(false);
comboBox->setEnabled(swappingEnabled);
comboBox->addItem(tr("center"), "center");
comboBox->addItem(tr("north"), "north");
comboBox->addItem(tr("east"), "east");
comboBox->addItem(tr("south"), "south");
comboBox->addItem(tr("west"), "west");
QString connectAt = m_modelPart->localProp("connect").toString();
for (int i = 0; i < comboBox->count(); i++) {
if (comboBox->itemData(i).toString().compare(connectAt) == 0) {
comboBox->setCurrentIndex(i);
break;
}
}
connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(terminalPointEntry(const QString &)));
returnWidget = comboBox;
returnProp = tr("connect to");
return true;
}
}
示例10: selectedColoring
FalseColoring::Type FalseColorDock::selectedColoring()
{
QComboBox *src = uisel->sourceBox;
QVariant boxData = src->itemData(src->currentIndex());
FalseColoring::Type coloringType = FalseColoring::Type(boxData.toInt());
return coloringType;
}
示例11: populateCoordinateSystemsList
void PointerCoordinatesWindow::populateCoordinateSystemsList()
{
Q_ASSERT(ui->coordinateSystemComboBox);
QComboBox* csys = ui->coordinateSystemComboBox;
//Save the current selection to be restored later
csys->blockSignals(true);
int index = csys->currentIndex();
QVariant selectedSystemId = csys->itemData(index);
csys->clear();
//For each algorithm, display the localized name and store the key as user
//data. Unfortunately, there's no other way to do this than with a cycle.
csys->addItem(q_("Right ascension/Declination (J2000.0)"), "RaDecJ2000");
csys->addItem(q_("Right ascension/Declination"), "RaDec");
csys->addItem(q_("Hour angle/Declination"), "HourAngle");
csys->addItem(q_("Ecliptic Longitude/Latitude"), "Ecliptic");
csys->addItem(q_("Ecliptic Longitude/Latitude (J2000.0)"), "EclipticJ2000");
csys->addItem(q_("Altitude/Azimuth"), "AltAzi");
csys->addItem(q_("Galactic Longitude/Latitude"), "Galactic");
//Restore the selection
index = csys->findData(selectedSystemId, Qt::UserRole, Qt::MatchCaseSensitive);
csys->setCurrentIndex(index);
csys->blockSignals(false);
}
示例12: slotChangedCheckBoxBooleanOperators
void RenderWindow::slotChangedCheckBoxBooleanOperators(bool state)
{
//TODO change number of fractals to 9 for boolean operators
if (state) ui->checkBox_hybrid_fractal_enable->setChecked(false);
gApplication->processEvents();
for(int i = 1; i <= NUMBER_OF_FRACTALS; i++)
{
QFrame *frame = ui->tabWidget_fractals->findChild<QFrame*>("frame_iterations_formula_" + QString::number(i));
if(i > 1)
{
frame->setEnabled(state);
ui->tabWidget_fractals->findChild<QScrollArea*>("scrollArea_fractal_" + QString::number(i))->setEnabled(state);
}
ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_formula_transform_" + QString::number(i))->setVisible(state);
QComboBox *comboBox = ui->tabWidget_fractals->findChild<QComboBox*>("comboBox_formula_"
+ QString::number(i));
fractal::enumCPixelAddition cPixelAddition = fractalList[comboBox->itemData(comboBox
->currentIndex()).toInt()].cpixelAddition;
if (cPixelAddition == fractal::cpixelAlreadyHas)
ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_c_constant_addition_"
+ QString::number(i))->setVisible(false);
else ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_c_constant_addition_"
+ QString::number(i))->setVisible(state);
}
ui->comboBox_delta_DE_function->setEnabled(!state);
}
示例13: groupCurrentIndexChanged
void ConnectFriendWizard::groupCurrentIndexChanged(int index)
{
QComboBox *comboBox = dynamic_cast<QComboBox*>(sender());
if (comboBox) {
groupId = comboBox->itemData(index, Qt::UserRole).toString();
}
}
示例14: 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);
}
示例15: ListChanged
void WidgetInfo::ListChanged(const char *setting)
{
QComboBox *combo = static_cast<QComboBox*>(widget);
obs_combo_format format = obs_property_list_format(property);
obs_combo_type type = obs_property_list_type(property);
QVariant data;
if (type == OBS_COMBO_TYPE_EDITABLE) {
data = combo->currentText();
} else {
int index = combo->currentIndex();
if (index != -1)
data = combo->itemData(index);
else
return;
}
switch (format) {
case OBS_COMBO_FORMAT_INVALID:
return;
case OBS_COMBO_FORMAT_INT:
obs_data_setint(view->settings, setting,
data.value<long long>());
break;
case OBS_COMBO_FORMAT_FLOAT:
obs_data_setdouble(view->settings, setting,
data.value<double>());
break;
case OBS_COMBO_FORMAT_STRING:
obs_data_setstring(view->settings, setting,
QT_TO_UTF8(data.toString()));
break;
}
}