本文整理汇总了C++中QComboBox类的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox类的具体用法?C++ QComboBox怎么用?C++ QComboBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QLabel
void PropertiesManager::createEmptySelectionProperties()
{
root->addItemsToolbar->addAction(root->actionAddRegime);
root->actionMove_Up->setEnabled(false);
root->actionMove_Down->setEnabled(false);
root->actionDeleteItems->setEnabled(false);
//component name
QLabel *label = new QLabel("<b>Component Class</b>");
addRow(label);
QLineEdit *edit_name = new QLineEdit();
edit_name->installEventFilter(&eventFilterObject);
edit_name->setValidator(componentNameValidator);
edit_name->setText(root->al->name);
connect(edit_name, SIGNAL(textEdited(QString)), root, SLOT(setComponentClassName(QString)));
addRow(tr("&Name:"),edit_name);
//component type
QComboBox *type = new QComboBox();
type->addItem("neuron_body");
type->addItem("weight_update");
type->addItem("postsynapse");
type->addItem("generic_component");
int typeVal;
if (root->al->type == "neuron_body")
typeVal = 0;
if (root->al->type == "weight_update")
typeVal = 1;
if (root->al->type == "postsynapse")
typeVal = 2;
if (root->al->type == "generic_component")
typeVal = 3;
type->setCurrentIndex(typeVal);
connect(type, SIGNAL(currentIndexChanged(QString)), root, SLOT(setComponentClassType(QString)));
addRow(tr("&Component Type:"),type);
//initial regime
QComboBox *initial_regime = new QComboBox();
bool match_init_r = false;
for (uint i=0; i<root->al->RegimeList.size(); i++){
initial_regime->addItem(root->al->RegimeList[i]->name);
if (root->al->initial_regime == root->al->RegimeList[i]){
initial_regime->setCurrentIndex(i);
match_init_r = true;
}
}
if (!match_init_r){
initial_regime->setCurrentIndex(-1);
}
connect(initial_regime, SIGNAL(currentIndexChanged(QString)), root, SLOT(setInitialRegime(QString)));
addRow(tr("&Initial Regime:"),initial_regime);
// add path combobox - NO LONGER USED
/*QComboBox * path = new QComboBox;
path->addItem("model");
path->addItem("temp");
path->addItem("lib");
path->setToolTip("Store the component externally as a file (temp) or internally in the library (lib)");
// select current path - NO LONGER USED
if (root->al->path == "")
root->al->path = "temp";
if (root->al->path == "model")
path->setCurrentIndex(0);
else if (root->al->path == "temp")
path->setCurrentIndex(1);
else if (root->al->path == "lib")
path->setCurrentIndex(2);
// disable model path
QModelIndex ind = path->model()->index(0,0);
path->model()->setData(ind, QVariant(0), Qt::UserRole-1);
addRow(tr("Path"), path);
connect(path, SIGNAL(currentIndexChanged(QString)), root, SLOT(setPath(QString)));*/
QPushButton * duplicate = new QPushButton("Duplicate component");
connect(duplicate, SIGNAL(clicked()), root->main, SLOT(duplicate_component()));
addWidget(duplicate);
QPushButton * remove = new QPushButton("Remove component");
connect(remove, SIGNAL(clicked()), root, SLOT(deleteComponent()));
addWidget(remove);
}
示例2: QGridLayout
void WidgetCtrlParameters::update(QMap<QString,ModPlusCtrls *> ctrlsMap)
{
QStringList models = ctrlsMap.keys();
// delete old widgets
for(int i=0;i<_widgetsCreated.size();i++)
delete _widgetsCreated.at(i);
_widgetsCreated.clear();
// clear layout
delete _layout;
_layout = new QGridLayout(this);
this->setLayout(_layout);
// empty maps
_ctrls.clear();
_comboBoxs.clear();
_parametersPbs.clear();
_compilePbs.clear();
QString curmodel;
ModPlusCtrls *curCtrls;
int iRow;
for(int i=0;i<models.size();i++)
{
curmodel = models.at(i);
curCtrls = ctrlsMap.value(curmodel);
// insert in _ctrls
_ctrls.insert(curmodel,curCtrls);
// add model combobox
QComboBox *newCb = new QComboBox(this);
//Ctrl box
ModPlusCtrl::Type curCtrlType;
ModPlusCtrl *curCtrl;
for(int i=0;i< curCtrls->keys().size();i++)
{
curCtrlType = curCtrls->keys().at(i);
curCtrl = curCtrls->value(curCtrlType);
newCb->addItem(curCtrl->name(),curCtrlType);
if(curCtrlType == curCtrls->currentCtrlType())
{
newCb->setCurrentIndex(i);
}
}
newCb->setEnabled(!_isResult);
_comboBoxs.insert(curmodel,newCb);
iRow = _layout->rowCount()+1;
QLabel *newLabel = new QLabel(curmodel,this);
_layout->addWidget(newLabel,iRow,0);
_layout->addWidget(newCb,iRow,1);
// add push buttons
QPushButton* newParamPb = new QPushButton("Parameters ...",this);
_layout->addWidget(newParamPb,iRow,2);
_parametersPbs.insert(curmodel,newParamPb);
QPushButton* newCompilePb = new QPushButton("Compile",this);
_layout->addWidget(newCompilePb,iRow,3);
_compilePbs.insert(curmodel,newCompilePb);
connect(newCb, SIGNAL(currentIndexChanged(int)),this, SLOT(changedCtrl()));
connect(newParamPb, SIGNAL(clicked()),this,SLOT(openCtrlParameters()));
connect(newCompilePb, SIGNAL(clicked()),this,SLOT(compile()));
// horizontal spacer
// QSpacerItem* spacer = new QSpacerItem(10,10,QSizePolicy::Expanding,QSizePolicy::Ignored);
// _layout->addItem(spacer,iRow,4);
_layout->setColumnStretch(4,10);
_widgetsCreated.push_back(newLabel);
_widgetsCreated.push_back(newCb);
_widgetsCreated.push_back(newParamPb);
_widgetsCreated.push_back(newCompilePb);
//_widgetsCreated.push_back(spacer);
}
}
示例3: switch
bool CDlgAlmCO2::eventFilter(QObject *o,QEvent *e)
{
QObject *obj[]={
m_cmbb_huxilv
,m_spb_huxi_high
,m_spb_huxi_low
,m_cmbb_hu
,m_spb_hu_high
,m_spb_hu_low
,m_cmbb_xi
,m_spb_xi_high
,m_spb_xi_low
,m_btn_ok,
m_btn_cancel
};
int iTotalObj = 11;//11
int iOkPos = iTotalObj -2;
int iCancelPos = iTotalObj -1;
if(e->type() == QEvent::KeyPress)
{
QKeyEvent *event=(QKeyEvent *)e;
switch (event->key()) {
case Qt::Key_Up:
case Qt::Key_Left:
if(bCursorSta == false)
{
if(iCursor == 0)
{
iCursor = iTotalObj-1;
}
else
{
iCursor -=1;
}
if((iCursor>=0) &&(iCursor<iOkPos))
{
QComboBox *p = (QComboBox *)obj[iCursor];
p->setFocus();
}
else
{
QPushButton *p = (QPushButton *)obj[iCursor];
p->setFocus();
}
}
else
{
if((iCursor == 1)||
(iCursor == 5)||
(iCursor == 2)||
(iCursor == 4)||
(iCursor == 7)||
(iCursor == 8)
)
{
QSpinBox *p = (QSpinBox *)obj[iCursor];
if(p->value()!= p->minimum())
{
p->setValue(p->value()-1);
}
else
{
p->setValue(p->maximum());
}
}
}
return true;
break;
case Qt::Key_Down:
case Qt::Key_Right:
if(bCursorSta == false)
{
if(iCursor == iTotalObj-1)
{
iCursor = 0;
}
else
{
iCursor +=1;
}
if((iCursor>=0) &&(iCursor<(iOkPos-1)))
{
QComboBox *p = (QComboBox *)obj[iCursor];
p->setFocus();
}
else
{
QPushButton *p = (QPushButton *)obj[iCursor];
p->setFocus();
}
}
else
{
//.........这里部分代码省略.........
示例4: switch
void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));
switch(pAbstractItem->type()) {
case MetaTreeItemTypes::SurfaceColorGyri: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri);
model->setData(index, data, Qt::DecorationRole);
return;
}
case MetaTreeItemTypes::SurfaceColorSulci: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci);
model->setData(index, data, Qt::DecorationRole);
return;
}
case MetaTreeItemTypes::RTDataColormapType: {
QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
QVariant data;
data.setValue(pColorMapType->currentText());
model->setData(index, data, MetaTreeItemRoles::RTDataColormapType);
model->setData(index, data, Qt::DisplayRole);
return;
}
case MetaTreeItemTypes::RTDataNormalizationValue: {
Spline* pSpline = static_cast<Spline*>(editor);
QVector3D returnVector;
returnVector = pSpline->getThreshold();
QString displayThreshold;
displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
QVariant dataDisplay;
dataDisplay.setValue(displayThreshold);
model->setData(index, dataDisplay, Qt::DisplayRole);
model->setData(index, returnVector, MetaTreeItemRoles::RTDataNormalizationValue);
return;
}
case MetaTreeItemTypes::RTDataTimeInterval: {
QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
QVariant data;
data.setValue(pSpinBox->value());
model->setData(index, data, MetaTreeItemRoles::RTDataTimeInterval);
model->setData(index, data, Qt::DisplayRole);
break;
}
case MetaTreeItemTypes::RTDataVisualizationType: {
QComboBox* pVisType = static_cast<QComboBox*>(editor);
QVariant data;
data.setValue(pVisType->currentText());
model->setData(index, data, MetaTreeItemRoles::RTDataVisualizationType);
model->setData(index, data, Qt::DisplayRole);
return;
}
case MetaTreeItemTypes::SurfaceColor: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, MetaTreeItemRoles::SurfaceColor);
model->setData(index, data, Qt::DecorationRole);
return;
}
case MetaTreeItemTypes::PointColor: {
QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
QColor color = pColorDialog->currentColor();
QVariant data;
data.setValue(color);
model->setData(index, data, MetaTreeItemRoles::PointColor);
model->setData(index, data, Qt::DecorationRole);
return;
}
case MetaTreeItemTypes::RTDataNumberAverages: {
QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
QVariant data;
//.........这里部分代码省略.........
示例5: WiresharkDialog
FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type) :
WiresharkDialog(parent, cf),
ui(new Ui::FollowStreamDialog),
follow_type_(type),
follower_(NULL),
show_type_(SHOW_ASCII),
truncated_(false),
save_as_(false)
{
ui->setupUi(this);
switch(type)
{
case FOLLOW_TCP:
follower_ = get_follow_by_name("TCP");
break;
case FOLLOW_SSL:
follower_ = get_follow_by_name("SSL");
break;
case FOLLOW_UDP:
follower_ = get_follow_by_name("UDP");
break;
case FOLLOW_HTTP:
follower_ = get_follow_by_name("HTTP");
break;
default :
g_assert_not_reached();
}
memset(&follow_info_, 0, sizeof(follow_info_));
follow_info_.show_stream = BOTH_HOSTS;
ui->teStreamContent->installEventFilter(this);
// XXX Use recent settings instead
resize(parent.width() * 2 / 3, parent.height());
QComboBox *cbcs = ui->cbCharset;
cbcs->blockSignals(true);
cbcs->addItem(tr("ASCII"), SHOW_ASCII);
cbcs->addItem(tr("C Arrays"), SHOW_CARRAY);
cbcs->addItem(tr("EBCDIC"), SHOW_EBCDIC);
cbcs->addItem(tr("Hex Dump"), SHOW_HEXDUMP);
cbcs->addItem(tr("UTF-8"), SHOW_UTF8);
cbcs->addItem(tr("YAML"), SHOW_YAML);
cbcs->addItem(tr("Raw"), SHOW_RAW);
cbcs->blockSignals(false);
b_filter_out_ = ui->buttonBox->addButton(tr("Hide this stream"), QDialogButtonBox::ActionRole);
connect(b_filter_out_, SIGNAL(clicked()), this, SLOT(filterOut()));
b_print_ = ui->buttonBox->addButton(tr("Print"), QDialogButtonBox::ActionRole);
connect(b_print_, SIGNAL(clicked()), this, SLOT(printStream()));
b_save_ = ui->buttonBox->addButton(tr("Save as" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole);
connect(b_save_, SIGNAL(clicked()), this, SLOT(saveAs()));
ProgressFrame::addToButtonBox(ui->buttonBox, &parent);
connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(helpButton()));
connect(ui->teStreamContent, SIGNAL(mouseMovedToTextCursorPosition(int)),
this, SLOT(fillHintLabel(int)));
connect(ui->teStreamContent, SIGNAL(mouseClickedOnTextCursorPosition(int)),
this, SLOT(goToPacketForTextPos(int)));
connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing()));
fillHintLabel(-1);
}
示例6: sender
void HardDiskDialog::userSetupChangedIndex(int index) {
QComboBox* box = (QComboBox*) sender();
QStringList userData = box->itemData(index).toStringList();
userMapping.insert(userData.at(0), userData.at(1));
}
示例7: it
void MainWindow::callOptionDialog (QVector<ConsoleInterface::optionDialogEntry> * options,bool * ret)
{
if (options->isEmpty()) return;
QVectorIterator<ConsoleInterface::optionDialogEntry> it(*options);
QDialog * d = new QDialog(this);
d->setModal(true);
QVBoxLayout * dbl = new QVBoxLayout();
d->setLayout(dbl);
QList <QWidget * > ents;
QHBoxLayout * sl;
QLabel * l;
QLineEdit * lew;
QCheckBox * chw;
QComboBox * cbl;
for(int i=0;i< (*options).size();i++)
{
sl = new QHBoxLayout();
l = new QLabel(d);
l->setText(it.next().text);
sl->addWidget(l);
if((*options)[i].type == ConsoleInterface::OPT_DEC)
{
lew = new QLineEdit(d);
lew->setValidator(new QIntValidator( d ));
QString s;
s.setNum((*options)[i].valueInt);
lew->setText(s);
sl->addWidget(lew);
ents.append(lew);
}
if((*options)[i].type == ConsoleInterface::OPT_HEX)
{
lew = new QLineEdit(d);
lew->setValidator(new QRegExpValidator(QRegExp("([A-Fa-f0-9][A-Fa-f0-9])+"),d));
QString s;
s.setNum((*options)[i].valueInt,16);
lew->setText(s);
sl->addWidget(lew);
ents.append(lew);
}
if((*options)[i].type == ConsoleInterface::OPT_STR)
{
lew = new QLineEdit(d);
lew->setValidator(NULL);
QString s = (*options)[i].valueStr;
lew->setText(s);
sl->addWidget(lew);
ents.append(lew);
}
if((*options)[i].type == ConsoleInterface::OPT_CHK)
{
chw = new QCheckBox(d);
chw->setChecked((*options)[i].valueInt == 0 ? false : true);
sl->addWidget(chw);
ents.append(chw);
}
if((*options)[i].type == ConsoleInterface::OPT_LIST)
{
cbl = new QComboBox(d);
cbl->addItems((*options)[i].variants);
sl->addWidget(cbl);
ents.append(cbl);
}
dbl->addLayout(sl);
}
QHBoxLayout * hbl = new QHBoxLayout(d);
QPushButton * obOK = new QPushButton(tr("OK"),d);
QPushButton * obCancel = new QPushButton(tr("Cancel"),d);
QPushButton * obAbort = new QPushButton(tr("Abort"),d);
connect(obOK,SIGNAL(clicked()),d,SLOT(accept()));
connect(obCancel,SIGNAL(clicked()),d,SLOT(reject()));
connect(obAbort,SIGNAL(clicked()),d,SLOT(reject()));
connect(obAbort,SIGNAL(clicked()),this,SLOT(on_stopButton_clicked()),Qt::QueuedConnection);
hbl->addStretch(10);
hbl->addWidget(obOK);
//.........这里部分代码省略.........
示例8: while
bool WulforUtil::getUserCommandParams(const UserCommand& uc, StringMap& params) {
StringList names;
string::size_type i = 0, j = 0;
const string cmd_str = uc.getCommand();
while((i = cmd_str.find("%[line:", i)) != string::npos) {
if ((j = cmd_str.find("]", (i += 7))) == string::npos)
break;
names.push_back(cmd_str.substr(i, j - i));
i = j + 1;
}
if (names.empty())
return true;
QDialog dlg(MainWindow::getInstance());
dlg.setWindowTitle(_q(uc.getDisplayName().back()));
QVBoxLayout *vlayout = new QVBoxLayout(&dlg);
std::vector<std::function<void ()> > valueFs;
for (const auto &name : names) {
QString caption = _q(name);
if (uc.adc()) {
caption.replace("\\\\", "\\");
caption.replace("\\s", " ");
}
int combo_sel = -1;
QString combo_caption = caption;
combo_caption.replace("//", "\t");
QStringList combo_values = combo_caption.split("/");
if (combo_values.size() > 2) {
QString tmp = combo_values.takeFirst();
bool isNumber = false;
combo_sel = combo_values.takeFirst().toInt(&isNumber);
if (!isNumber || combo_sel >= combo_values.size())
combo_sel = -1;
else
caption = tmp;
}
QGroupBox *box = new QGroupBox(caption, &dlg);
QHBoxLayout *hlayout = new QHBoxLayout(box);
if (combo_sel >= 0) {
for (auto &val : combo_values)
val.replace("\t", "/");
QComboBox *combo = new QComboBox(box);
hlayout->addWidget(combo);
combo->addItems(combo_values);
combo->setEditable(true);
combo->setCurrentIndex(combo_sel);
combo->lineEdit()->setReadOnly(true);
valueFs.push_back([combo, name, ¶ms] {
params["line:" + name] = combo->currentText().toStdString();
});
} else {
QLineEdit *line = new QLineEdit(box);
hlayout->addWidget(line);
valueFs.push_back([line, name, ¶ms] {
params["line:" + name] = line->text().toStdString();
});
}
vlayout->addWidget(box);
}
QDialogButtonBox *buttonBox = new QDialogButtonBox(&dlg);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
vlayout->addWidget(buttonBox);
dlg.setFixedHeight(vlayout->sizeHint().height());
connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
if (dlg.exec() != QDialog::Accepted)
return false;
for (const auto &fs : valueFs)
fs();
return true;
}
示例9: if
void QgsSnappingDialog::update()
{
if ( !mMapCanvas )
return;
QSettings myQsettings;
bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();
double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();
int defaultSnappingStringIdx = 0;
if ( defaultSnappingString == "to vertex" )
{
defaultSnappingStringIdx = 0;
}
else if ( defaultSnappingString == "to segment" )
{
defaultSnappingStringIdx = 1;
}
else //to vertex and segment
{
defaultSnappingStringIdx = 2;
}
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );
mLayerTreeWidget->clear();
QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap< QString, QgsMapLayer *>::iterator it;
for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
{
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !currentVectorLayer || currentVectorLayer->geometryType() == QGis::NoGeometry )
continue;
//snap to layer yes/no
QTreeWidgetItem *item = new QTreeWidgetItem( mLayerTreeWidget );
QCheckBox *cbxEnable = new QCheckBox( mLayerTreeWidget );
mLayerTreeWidget->setItemWidget( item, 0, cbxEnable );
item->setData( 0, Qt::UserRole, currentVectorLayer->getLayerID() );
item->setText( 1, currentVectorLayer->name() );
//snap to vertex/ snap to segment
QComboBox *cbxSnapTo = new QComboBox( mLayerTreeWidget );
cbxSnapTo->insertItem( 0, tr( "to vertex" ) );
cbxSnapTo->insertItem( 1, tr( "to segment" ) );
cbxSnapTo->insertItem( 2, tr( "to vertex and segment" ) );
cbxSnapTo->setCurrentIndex( defaultSnappingStringIdx );
mLayerTreeWidget->setItemWidget( item, 2, cbxSnapTo );
//snapping tolerance
QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget );
QDoubleValidator *validator = new QDoubleValidator( leTolerance );
leTolerance->setValidator( validator );
leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) );
mLayerTreeWidget->setItemWidget( item, 3, leTolerance );
//snap to vertex/ snap to segment
QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget );
cbxUnits->insertItem( 0, tr( "map units" ) );
cbxUnits->insertItem( 1, tr( "pixels" ) );
cbxUnits->setCurrentIndex( defaultSnappingUnit );
mLayerTreeWidget->setItemWidget( item, 4, cbxUnits );
QCheckBox *cbxAvoidIntersection = 0;
if ( currentVectorLayer->geometryType() == QGis::Polygon )
{
cbxAvoidIntersection = new QCheckBox( mLayerTreeWidget );
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
}
int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
if ( idx < 0 )
{
// no settings for this layer yet
continue;
}
cbxEnable->setChecked( enabledList[ idx ] == "enabled" );
int snappingStringIdx = 0;
if ( snapToList[idx] == "to_vertex" )
{
snappingStringIdx = 0;
}
else if ( snapToList[idx] == "to_segment" )
{
snappingStringIdx = 1;
//.........这里部分代码省略.........
示例10: QToolBar
//.........这里部分代码省略.........
//Horizontal alignment
action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
alignButton->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));
// Energy-based layout
action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar);
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("9", "Energy-based layout")));
alignButton->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout()));
// selection group button
QToolButton *selectButton = new QToolButton(mToolBar);
selectButton->setIcon(findIcon("tool-select-group.png"));
selectButton->setPopupMode(QToolButton::InstantPopup);
mToolBar->addWidget(selectButton);
// input/output selection
action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
action->setCheckable(false);
selectButton->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput()));
// sbgraph selection
action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar);
action->setCheckable(false);
selectButton->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph()));
mToolBar->addSeparator();
action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar);
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("0", "Export image")));
mToolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onExportImage()));
action = new QAction(findIcon("tool-print.png"), tr("Print"), mToolBar);
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("0", "Print")));
mToolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onPrint()));
//
mToolBar->addSeparator();
//Scale combobox
QComboBox* b = new QComboBox(mToolBar);
b->setFixedWidth(55);
b->setEditable(true);
b->setInsertPolicy(QComboBox::NoInsert);
b->addItems(SCgWindow::mScales);
b->setCurrentIndex(mScales.indexOf("100"));
mZoomFactorLine = b->lineEdit();
mZoomFactorLine->setInputMask("D90%");
mToolBar->addWidget(b);
connect(mZoomFactorLine, SIGNAL(textChanged(const QString&)), mView, SLOT(setScale(const QString&)));
connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal)));
//
//Zoom in
//action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar);
action = new QAction("+",mToolBar);
action->setToolTip(tr("Zoom in"));
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("+", "Zoom in")));
mToolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn()));
//slider scale
mZoomSlider = new QSlider();
mZoomSlider->setFixedWidth(40);
mZoomSlider->setSizeIncrement(25,180/25);
mZoomSlider->setFixedHeight(180);
mZoomSlider->setToolTip(tr("Scale"));
mZoomSlider->setMinimum(mZoomSliderMinValue);
mZoomSlider->setValue(100);
mZoomSlider->setMaximum(mZoomSliderMaxValue);
mToolBar->addWidget(mZoomSlider);
connect(mZoomSlider,SIGNAL(valueChanged(int)),this,SLOT(onmZoomSliderMove(int)));
//Zoom out
// action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar);
action = new QAction("-", mToolBar);
action->setToolTip(tr("Zoom out"));
action->setCheckable(false);
action->setShortcut(QKeySequence(tr("-", "Zoom out")));
mToolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut()));
mToolBar->setWindowTitle(tr("SCg Tools"));
mToolBar->setObjectName("SCgMainToolBar");
//! @bug toolbar state is not saved
mToolBar->setMovable(false);
}
示例11: WiresharkDialog
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) :
WiresharkDialog(parent, cf),
ui(new Ui::SequenceDialog),
info_(info),
num_items_(0),
packet_num_(0),
sequence_w_(1)
{
ui->setupUi(this);
loadGeometry(parent.width(), parent.height() * 4 / 5);
QCustomPlot *sp = ui->sequencePlot;
setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow"));
if (!info_) {
info_ = new SequenceInfo(sequence_analysis_info_new());
info_->sainfo()->type = SEQ_ANALYSIS_ANY;
info_->sainfo()->all_packets = TRUE;
} else {
info_->ref();
num_items_ = sequence_analysis_get_nodes(info_->sainfo());
}
seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
sp->addPlottable(seq_diagram_);
// When dragging is enabled it's easy to drag past the lower and upper
// bounds of each axis. Disable it for now.
//sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);
//sp->setInteractions(QCP::iRangeDrag);
sp->xAxis->setVisible(false);
sp->xAxis->setPadding(0);
sp->xAxis->setLabelPadding(0);
sp->xAxis->setTickLabelPadding(0);
QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25));
base_pen.setWidthF(0.5);
sp->xAxis2->setBasePen(base_pen);
sp->yAxis->setBasePen(base_pen);
sp->yAxis2->setBasePen(base_pen);
sp->xAxis2->setVisible(true);
sp->yAxis2->setVisible(true);
key_text_ = new QCPItemText(sp);
key_text_->setText(tr("Time"));
sp->addItem(key_text_);
key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter);
key_text_->position->setType(QCPItemPosition::ptAbsolute);
key_text_->setClipToAxisRect(false);
comment_text_ = new QCPItemText(sp);
comment_text_->setText(tr("Comment"));
sp->addItem(comment_text_);
comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter);
comment_text_->position->setType(QCPItemPosition::ptAbsolute);
comment_text_->setClipToAxisRect(false);
one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
ui->horizontalScrollBar->setSingleStep(100 / one_em_);
ui->verticalScrollBar->setSingleStep(100 / one_em_);
ui->gridLayout->setSpacing(0);
connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));
ctx_menu_.addAction(ui->actionReset);
ctx_menu_.addSeparator();
ctx_menu_.addAction(ui->actionMoveRight10);
ctx_menu_.addAction(ui->actionMoveLeft10);
ctx_menu_.addAction(ui->actionMoveUp10);
ctx_menu_.addAction(ui->actionMoveDown10);
ctx_menu_.addAction(ui->actionMoveRight1);
ctx_menu_.addAction(ui->actionMoveLeft1);
ctx_menu_.addAction(ui->actionMoveUp1);
ctx_menu_.addAction(ui->actionMoveDown1);
ctx_menu_.addSeparator();
ctx_menu_.addAction(ui->actionGoToPacket);
ctx_menu_.addAction(ui->actionGoToNextPacket);
ctx_menu_.addAction(ui->actionGoToPreviousPacket);
ui->showComboBox->setCurrentIndex(0);
ui->addressComboBox->setCurrentIndex(0);
QComboBox *fcb = ui->flowComboBox;
fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);
ui->flowComboBox->setCurrentIndex(info_->sainfo()->type);
if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) {
ui->flowComboBox->blockSignals(true);
ui->controlFrame->hide();
}
QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));
//.........这里部分代码省略.........
示例12: setModelData
void QtComboBoxDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
QComboBox* comboBox = static_cast<QComboBox*>(editor);
model->setData(index, comboBox->currentText(), Qt::EditRole);
model->setData(index, comboBox->currentData(Qt::UserRole), Qt::UserRole);
}
示例13: mergedIcon
void CUcontent_Adjustments::setupAdjustmentsTable()
{
bool enable = false;
bool ok = false;
unsigned char k = 0;
QTableWidgetItem *tableItem = NULL;
ModQDoubleSpinBox *spinBox = NULL;
QComboBox *comboBox = NULL;
QIdPushButton *saveButton = NULL;
QPushButton *resetButton = NULL;
QPixmap leftIcon, rightIcon;
QPixmap mergedIcon(54, 22);
QStringList selectableScaledValueStr;
QString helpScaledValueStr = 0;
double minScaledValue = 0;
double maxScaledValue = 0;
double defaultScaledValue = 0;
double minSingleStepFromPrecision = 0;
double minSingleStepFromRaw = 0;
bool calcerror = false;
// Create "Save"-icon:
leftIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/go-next.png") );
rightIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/drive-harddisk.png") );
mergedIcon.fill(Qt::transparent);
QPainter painter(&mergedIcon);
painter.drawTiledPixmap( 0, 0, 22, 22, leftIcon );
painter.drawTiledPixmap( 32, 0, 22, 22, rightIcon );
QIcon saveButton_icon( mergedIcon );
// Create "Reset"-icon:
leftIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/go-first.png") );
mergedIcon.fill(Qt::transparent);
painter.drawTiledPixmap( 0, 0, 22, 22, leftIcon );
painter.drawTiledPixmap( 32, 0, 22, 22, rightIcon );
QIcon resetButton_icon( mergedIcon );
// Clear Table:
adjustments_tableWidget->clearContents();
// Enable/Disable GUI-elements:
title_label->setEnabled( enable );
adjustments_tableWidget->setEnabled( enable );
nonPermanentInfo_label->setEnabled( enable );
// Increase nr. of table rows if necessary:
if (_supportedAdjustments.size() && (static_cast<unsigned int>(adjustments_tableWidget->rowCount()) < _supportedAdjustments.size()))
adjustments_tableWidget->setRowCount( _supportedAdjustments.size() + 2 );
// Fill Table:
for (k=0; k<_supportedAdjustments.size(); k++)
{
// Title:
tableItem = new QTableWidgetItem( _supportedAdjustments.at(k).title );
adjustments_tableWidget->setItem(k, 0, tableItem);
// Current Value:
tableItem = new QTableWidgetItem( "???" );
tableItem->setTextAlignment(Qt::AlignCenter);
adjustments_tableWidget->setItem(k, 1, tableItem);
// New Value:
if (_newValueSelWidgetType.at(k))
{
// Get selectable scaled values:
selectableScaledValueStr.clear();
getSelectableScaledValueStrings(_supportedAdjustments.at(k).formula, &selectableScaledValueStr);
// Setup and insert selection-Combobox:
comboBox = new QComboBox();
comboBox->addItems( selectableScaledValueStr );
adjustments_tableWidget->setCellWidget ( k, 2, comboBox );
}
else
{
// Calculate and set min/max:
ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawMin, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr);
if (ok)
minScaledValue = helpScaledValueStr.toDouble(&ok);
if (ok)
ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawMax, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr);
if (ok)
maxScaledValue = helpScaledValueStr.toDouble(&ok);
if (ok)
ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawDefault, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr);
if (ok)
defaultScaledValue = helpScaledValueStr.toDouble(&ok);
if (!ok)
{
calcerror = true;
continue; // continue with next adjustment value
}
spinBox = new ModQDoubleSpinBox();
// put spinbox into the table:
adjustments_tableWidget->setCellWidget ( k, 2, spinBox );
/* NOTE: we do this here, because some spinbox functions don't work as expected (Qt-bugs ?) if spinBox is not visible yet */
// Set adjustable range:
if (minScaledValue > maxScaledValue)
spinBox->setRange(maxScaledValue, minScaledValue);
else
spinBox->setRange(minScaledValue, maxScaledValue);
// Calculate and set step size:
minSingleStepFromPrecision = pow(10, (-1*_supportedAdjustments.at(k).precision));
minSingleStepFromRaw = (maxScaledValue - minScaledValue) / (_supportedAdjustments.at(k).rawMax - _supportedAdjustments.at(k).rawMin);
/* NOTE: this only works for constant step size ! */
if (minSingleStepFromRaw > minSingleStepFromPrecision)
spinBox->setSingleStep( minSingleStepFromRaw );
else
//.........这里部分代码省略.........
示例14: GUIPlugin
OperatorOverlay::OperatorOverlay()
: GUIPlugin()
{
init();
this->counter = 0;
// Set the frame background and foreground colors
this->setStyleSheet(
"QFrame { background-color : rgba(100, 100, 100, 255); color : white; }");
// Create the main layout
QHBoxLayout *mainLayout = new QHBoxLayout;
// Create the frame to hold all the widgets
QFrame *mainFrame = new QFrame();
// Create the layout that sits inside the frame
QVBoxLayout *frameLayout = new QVBoxLayout();
// ACTIONS chooser
QLabel *operatorLabel = new QLabel(tr("Operator:"));
frameLayout->addWidget(operatorLabel);
QPushButton *setTargetButton = new QPushButton(tr("Selection to Target"));
connect(setTargetButton, SIGNAL(clicked()), this, SLOT(setTarget()));
frameLayout->addWidget(setTargetButton);
targetLabel = new QLineEdit(tr("target_name"));
targetLabel->setEnabled(false);
frameLayout->addWidget(targetLabel);
QPushButton *MoveToButton = new QPushButton( "Move To");
MoveToButton->setCheckable( true );
connect(MoveToButton, SIGNAL(clicked()), this, SLOT(moveOperator()));
frameLayout->addWidget(MoveToButton);
// ROBOT chooser
QLabel *robotLabel = new QLabel(tr("Robot:"));
frameLayout->addWidget(robotLabel);
QComboBox *robotChooser = new QComboBox();
robotChooser->addItem("ALL");
robotChooser->addItem("A");
robotChooser->addItem("Donkey");
robotChooser->addItem("Hawk");
robotChooser->addItem("Wasp1");
robotChooser->addItem("Wasp2");
robotChooser->addItem("Wasp3");
robotChooser->addItem("Wasp4");
///FIXME add SIGNAL
frameLayout->addWidget(robotChooser);
// ACTIONS chooser
QLabel *actionLabel = new QLabel(tr("Commands:"));
frameLayout->addWidget(actionLabel);
QComboBox *actionChooser = new QComboBox();
actionChooser->addItem("Perceive");
actionChooser->addItem("Search");
actionChooser->addItem("Recharge");
actionChooser->addItem("Drop box");
actionChooser->addItem("Pick up box");
actionChooser->addItem("Follow e");
actionChooser->addItem("Come Here");
frameLayout->addWidget(actionChooser);
QPushButton *executeAction = new QPushButton(tr("Execute"));
//connect(button2, SIGNAL(clicked()), this, SLOT(OnButton()));
frameLayout->addWidget(executeAction);
///LOGGING
QLabel *logLayout = new QLabel("Logging:");
frameLayout->addWidget(logLayout);
QPushButton *logButton = new QPushButton( "Logging!");
logButton->setCheckable( true );
frameLayout->addWidget(logButton);
QPushButton *exportButton = new QPushButton(tr("Export log"));
//connect(button2, SIGNAL(clicked()), this, SLOT(OnButton()));
frameLayout->addWidget(exportButton);
// Add frameLayout to the frame
mainFrame->setLayout(frameLayout);
// Add the frame to the main layout
mainLayout->addWidget(mainFrame);
// Remove margins to reduce space
frameLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setContentsMargins(0, 0, 0, 0);
this->setLayout(mainLayout);
//.........这里部分代码省略.........
示例15: QWidget
void ApplicationWindow::addTpgTab(int m_winWidth)
{
QWidget *t = new QWidget(m_tabs);
QVBoxLayout *vbox = new QVBoxLayout(t);
QWidget *w = new QWidget(t);
QCheckBox *check;
QComboBox *combo;
QSpinBox *spin;
m_col = m_row = 0;
m_cols = 4;
for (int j = 0; j < m_cols; j++) {
m_maxw[j] = 0;
}
vbox->addWidget(w);
QGridLayout *grid = new QGridLayout(w);
QLabel *title_tab = new QLabel("Test Pattern Generator", parentWidget());
QFont f = title_tab->font();
f.setBold(true);
title_tab->setFont(f);
grid->addWidget(title_tab, m_row, m_col, 1, m_cols, Qt::AlignLeft);
grid->setRowMinimumHeight(m_row, 25);
m_row++;
QFrame *m_line = new QFrame(grid->parentWidget());
m_line->setFrameShape(QFrame::HLine);
m_line->setFrameShadow(QFrame::Sunken);
grid->addWidget(m_line, m_row, m_col, 1, m_cols, Qt::AlignVCenter);
m_row++;
m_tabs->addTab(t, "Test Pattern Generator");
grid->addWidget(new QWidget(w), grid->rowCount(), 0, 1, m_cols);
addLabel(grid, "Test Pattern");
combo = new QComboBox(w);
for (int i = 0; tpg_pattern_strings[i]; i++)
combo->addItem(tpg_pattern_strings[i]);
addWidget(grid, combo);
connect(combo, SIGNAL(activated(int)), SLOT(testPatternChanged(int)));
m_row++;
m_col = 0;
addLabel(grid, "Horizontal Movement");
combo = new QComboBox(w);
combo->addItem("Move Left Fast");
combo->addItem("Move Left");
combo->addItem("Move Left Slow");
combo->addItem("No Movement");
combo->addItem("Move Right Slow");
combo->addItem("Move Right");
combo->addItem("Move Right Fast");
combo->setCurrentIndex(3);
addWidget(grid, combo);
connect(combo, SIGNAL(activated(int)), SLOT(horMovementChanged(int)));
addLabel(grid, "Video Aspect Ratio");
combo = new QComboBox(w);
combo->addItem("Source Width x Height");
combo->addItem("4x3");
combo->addItem("14x9");
combo->addItem("16x9");
combo->addItem("16x9 Anamorphic");
addWidget(grid, combo);
connect(combo, SIGNAL(activated(int)), SLOT(videoAspectRatioChanged(int)));
addLabel(grid, "Vertical Movement");
combo = new QComboBox(w);
combo->addItem("Move Up Fast");
combo->addItem("Move Up");
combo->addItem("Move Up Slow");
combo->addItem("No Movement");
combo->addItem("Move Down Slow");
combo->addItem("Move Down");
combo->addItem("Move Down Fast");
combo->setCurrentIndex(3);
addWidget(grid, combo);
connect(combo, SIGNAL(activated(int)), SLOT(vertMovementChanged(int)));
addLabel(grid, "Show Border");
check = new QCheckBox(w);
addWidget(grid, check);
connect(check, SIGNAL(stateChanged(int)), SLOT(showBorderChanged(int)));
addLabel(grid, "Insert SAV Code in Image");
check = new QCheckBox(w);
addWidget(grid, check);
connect(check, SIGNAL(stateChanged(int)), SLOT(insSAVChanged(int)));
addLabel(grid, "Show Square");
check = new QCheckBox(w);
addWidget(grid, check);
connect(check, SIGNAL(stateChanged(int)), SLOT(showSquareChanged(int)));
addLabel(grid, "Insert EAV Code in Image");
check = new QCheckBox(w);
addWidget(grid, check);
connect(check, SIGNAL(stateChanged(int)), SLOT(insEAVChanged(int)));
//.........这里部分代码省略.........