本文整理汇总了C++中QComboBox::setSizeAdjustPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setSizeAdjustPolicy方法的具体用法?C++ QComboBox::setSizeAdjustPolicy怎么用?C++ QComboBox::setSizeAdjustPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setSizeAdjustPolicy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createEditor
QWidget* ComboDelegate::createEditor( QWidget* parent,
const QStyleOptionViewItem&,
const QModelIndex&) const {
QComboBox* combo = new QComboBox(parent);
combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
combo->setMinimumHeight(ComboDelegate::MINIMUM_EDITOR_HEIGHT);
return combo;
}
示例2: setRow
void QgsVectorLayerProperties::setRow( int row, int idx, const QgsField &field )
{
tblAttributes->setItem( row, 0, new QTableWidgetItem( QString::number( idx ) ) );
tblAttributes->setItem( row, 1, new QTableWidgetItem( field.name() ) );
tblAttributes->setItem( row, 2, new QTableWidgetItem( field.typeName() ) );
tblAttributes->setItem( row, 3, new QTableWidgetItem( QString::number( field.length() ) ) );
tblAttributes->setItem( row, 4, new QTableWidgetItem( QString::number( field.precision() ) ) );
tblAttributes->setItem( row, 5, new QTableWidgetItem( field.comment() ) );
for ( int i = 0; i < 6; i++ )
tblAttributes->item( row, i )->setFlags( tblAttributes->item( row, i )->flags() & ~Qt::ItemIsEditable );
QComboBox *cb = new QComboBox();
cb->addItem( tr( "line edit" ), QgsVectorLayer::LineEdit );
cb->addItem( tr( "unique values" ), QgsVectorLayer::UniqueValues );
cb->addItem( tr( "unique values (editable)" ), QgsVectorLayer::UniqueValuesEditable );
cb->addItem( tr( "value map" ), QgsVectorLayer::ValueMap );
cb->addItem( tr( "classification" ), QgsVectorLayer::Classification );
cb->addItem( tr( "range (editable)" ), QgsVectorLayer::EditRange );
cb->addItem( tr( "range (slider)" ), QgsVectorLayer::SliderRange );
cb->addItem( tr( "file name" ), QgsVectorLayer::FileName );
cb->setSizeAdjustPolicy( QComboBox::AdjustToContentsOnFirstShow );
cb->setCurrentIndex( layer->editType( idx ) );
tblAttributes->setCellWidget( row, 6, cb );
if ( layer->editType( idx ) == QgsVectorLayer::ValueMap )
{
// TODO: create a gui for value maps
QStringList mapList;
QMap<QString, QVariant> &map = layer->valueMap( idx );
for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++ )
{
QgsDebugMsg( QString( "idx:%1 key:%2 value:%3" ).arg( idx ).arg( mit.key() ).arg( mit.value().toString() ) );
if ( mit.value().isNull() )
mapList << mit.key();
else
mapList << QString( "%1=%2" ).arg( mit.key() ).arg( mit.value().toString() );
}
tblAttributes->setItem( row, 7, new QTableWidgetItem( mapList.join( ";" ) ) );
}
else if ( layer->editType( idx ) == QgsVectorLayer::EditRange ||
layer->editType( idx ) == QgsVectorLayer::SliderRange )
{
tblAttributes->setItem(
row, 7,
new QTableWidgetItem( QString( "%1;%2;%3" )
.arg( layer->range( idx ).mMin.toString() )
.arg( layer->range( idx ).mMax.toString() )
.arg( layer->range( idx ).mStep.toString() )
)
);
}
}
示例3: createSelectorWithVHDLStandardLibraries
//-----------------------------------------------------------------------------
// Function: PortsDelegate::createSelectorWithVHDLStandardLibraries()
//-----------------------------------------------------------------------------
QWidget* PortsDelegate::createSelectorWithVHDLStandardLibraries(QWidget* parent) const
{
QComboBox* combo = new QComboBox(parent);
combo->setEditable(true);
combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
for (unsigned int i = 0;i < VhdlGeneral::VHDL_TYPEDEF_COUNT; ++i)
{
combo->addItem(VhdlGeneral::VHDL_TYPE_DEFINITIONS[i]);
}
return combo;
}
示例4: createEditor
QWidget* MashStepItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/*option*/, const QModelIndex &index) const
{
if( index.column() == MASHSTEPTYPECOL )
{
QComboBox *box = new QComboBox(parent);
box->addItem("Infusion");
box->addItem("Temperature");
box->addItem("Decoction");
box->setSizeAdjustPolicy(QComboBox::AdjustToContents);
return box;
}
else
return new QLineEdit(parent);
}
示例5: 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);
}
示例6: buildWidget
void PartyEditor::buildWidget()
{
QGroupBox *partyGBE = new QGroupBox(tr("Équipe"), this);
QGridLayout *partyGBL = new QGridLayout(partyGBE);
partyGBL->addWidget(new QLabel(tr("Menus :")), 0, 0);
partyGBL->addWidget(new QLabel(tr("À l'écran :")), 1, 0);
QList<QIcon> icons;
int i, j;
for(j=0 ; j<11 ; ++j) {
icons.append(QIcon(QString(":/images/icons/perso%1.png").arg(j)));
}
QComboBox *comboBox;
for(i=0 ; i<3 ; ++i)
{
partyE.append(comboBox = new QComboBox(partyGBE));
comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
comboBox->addItem("-", 255);
for(j=0 ; j<8 ; ++j) {
comboBox->addItem(icons.at(j), Data::names().at(j), j);
}
partyGBL->addWidget(comboBox, 0, i+1);
partySortE.append(comboBox = new QComboBox(partyGBE));
comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
comboBox->addItem("-", 255);
for(j=0 ; j<11 ; ++j) {
comboBox->addItem(icons.at(j), Data::names().at(j), j);
}
partyGBL->addWidget(comboBox, 1, i+1);
}
dreamE = new QCheckBox(tr("Seule l'équipe principale est visible (rêve avec Laguna)"), partyGBE);
partyGBL->addWidget(dreamE, 2, 0, 1, 4, Qt::AlignLeft);
QGroupBox *positionGBE = new QGroupBox(tr("Position"), this);
QSpinBox *spinBox;
QGridLayout *positionGBL = new QGridLayout(positionGBE);
positionGBL->addWidget(new QLabel(tr("X :")), 0, 1);
positionGBL->addWidget(new QLabel(tr("Y :")), 0, 2);
positionGBL->addWidget(new QLabel(tr("Triangle ID :")), 0, 3);
positionGBL->addWidget(new QLabel(tr("Direction :")), 0, 4);
for(i=0 ; i<3 ; ++i) {
positionGBL->addWidget(new QLabel(tr("Membre %1 :").arg(i+1)), i+1, 0);
xE.append(spinBox = new QSpinBox(positionGBE));
spinBox->setRange(-32768, 32767);
positionGBL->addWidget(spinBox, i+1, 1);
yE.append(spinBox = new QSpinBox(positionGBE));
spinBox->setRange(-32768, 32767);
positionGBL->addWidget(spinBox, i+1, 2);
idE.append(spinBox = new SpinBox16(positionGBE));
positionGBL->addWidget(spinBox, i+1, 3);
dirE.append(spinBox = new SpinBox8(positionGBE));
positionGBL->addWidget(spinBox, i+1, 4);
}
moduleE = new QComboBox(positionGBE);
moduleE->addItem(tr("Terrain"), 0);
moduleE->addItem(tr("Terrain"), 1);
moduleE->addItem(tr("Mappemonde"), 2);
moduleE->addItem(tr("Combat"), 3);
mapE = new QComboBox(positionGBE);
mapE->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
QStringList mapList = Data::maplist();
i=0;
foreach(const QString &mapName, mapList) {
mapE->addItem(mapName, i++);
}
示例7: setTitle
//.........这里部分代码省略.........
m_editMaskBrushRadius = new QSpinBox(editMaskToolOptions);
connect(m_editMaskBrushRadius,SIGNAL(valueChanged(int)),editor->editorView(),SLOT(updateEditMaskCursor(int)));
m_editMaskBrushRadius->setValue(5);
grid->addWidget(m_editMaskBrushRadius,2,2,1,2);
QPushButton * loadMaskFromFile = new QPushButton("Load mask from file",
editMaskToolOptions);
loadMaskFromFile->setToolTip("Load a mask from a black and white png file.\n"
"White is included in the mask and black excluded.");
connect(loadMaskFromFile,SIGNAL(clicked()),this,SLOT(onLoadMaskFromFile()));
grid->addWidget(loadMaskFromFile,3,1,1,3);
QPushButton * invertMask = new QPushButton("Invert mask",
editMaskToolOptions);
invertMask->setToolTip("Inverts the mask of the current image.");
connect(invertMask,SIGNAL(clicked()),this,SLOT(onInvertMask()));
grid->addWidget(invertMask,4,1,1,3);
grid->setRowStretch(0,100);
grid->setColumnStretch(0,100);
grid->setRowStretch(5,100);
grid->setColumnStretch(5,100);
toolOptionsLayout->addWidget(editMaskToolOptions);
filterToolOptions = new QWidget(toolOptions);
grid = new QGridLayout(filterToolOptions);
filterToolOptions->setLayout(grid);
grid->addWidget(new QLabel(tr("Filter Type:"),filterToolOptions),0,0);
QComboBox * comboBox = new QComboBox(filterToolOptions);
comboBox->addItem("Gaussian Radial");
comboBox->addItem("Horizontal bands removal");
comboBox->setMinimumContentsLength(10);
comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
grid->addWidget(comboBox,0,1);
grid->setRowStretch(2,100);
grid->setColumnStretch(2,100);
toolOptionsLayout->addWidget(filterToolOptions);
selectionToolOptions = new QWidget(toolOptions);
grid = new QGridLayout(selectionToolOptions);
selectionToolOptions->setLayout(grid);
label = new QLabel("Mode:",selectionToolOptions);
label->setAlignment(Qt::AlignRight);
grid->addWidget(label,0,0);
QToolButton * button = new QToolButton(selectionToolOptions);
button->setIcon(QIcon(":images/selection.png"));
button->setToolTip("Set selection");
button->setCheckable(true);
button->setChecked(true);
button->setAutoExclusive(true);
connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeSet()));
grid->addWidget(button,0,1);
button = new QToolButton(selectionToolOptions);
button->setIcon(QIcon(":images/selection_union.png"));
button->setToolTip("Add to selection");
button->setCheckable(true);
button->setAutoExclusive(true);
connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeUnite()));
grid->addWidget(button,0,2);
button = new QToolButton(selectionToolOptions);
button->setIcon(QIcon(":images/selection_subtract.png"));
button->setToolTip("Remove from selection");
button->setCheckable(true);
button->setAutoExclusive(true);
connect(button,SIGNAL(clicked()),this,SLOT(setSelectionModeSubtract()));
示例8:
void
fixComboBoxViewWidth(QComboBox &comboBox) {
comboBox.setSizeAdjustPolicy(QComboBox::AdjustToContents);
comboBox.view()->setMinimumWidth(comboBox.sizeHint().width());
}
示例9: buildWidget
void PreviewEditor::buildWidget()
{
previewWidget = new PreviewWidget(this);
locationIDE = new QComboBox(this);
int i=0;
foreach(const QString &loc, Data::locations().list())
locationIDE->addItem(loc, i++);
saveCountE = new SpinBox16(this);
curSaveE = new SpinBox32(this);
autoGroup = new QGroupBox(tr("Auto."));
autoGroup->setCheckable(true);
hpLeaderE = new SpinBox16(autoGroup);
hpMaxLeaderE = new SpinBox16(autoGroup);
gilsE = new SpinBox32(autoGroup);
timeE = new TimeWidget(autoGroup);
nivLeaderE = new SpinBox8(autoGroup);
discE = new SpinBox32(autoGroup);
discE->setRange(1, double(MAX_INT32) + 1.0);
QComboBox *comboBox;
QList<QIcon> icons;
for(int i=0 ; i<16 ; ++i) {
icons.append(QIcon(QString(":/images/icons/perso%1.png").arg(i)));
}
for(int i=0 ; i<3 ; ++i) {
partyE.append(comboBox = new QComboBox(autoGroup));
comboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
comboBox->addItem("-", 255);
for(int j=0 ; j<16 ; ++j) {
comboBox->addItem(icons.at(j), Data::names().at(j), j);
}
}
QHBoxLayout *partyL = new QHBoxLayout;
partyL->addWidget(partyE.first());
partyL->addWidget(partyE.at(1));
partyL->addWidget(partyE.last());
partyL->setContentsMargins(QMargins());
QGridLayout *autoL = new QGridLayout(autoGroup);
autoL->addWidget(new QLabel(tr("HP leader (inutilisé)"), autoGroup), 0, 0);
autoL->addWidget(hpLeaderE, 0, 1);
autoL->addWidget(new QLabel(tr("HP max. leader (inutilisé)"), autoGroup), 0, 2);
autoL->addWidget(hpMaxLeaderE, 0, 3);
autoL->addWidget(new QLabel(tr("Niveau leader"), autoGroup), 0, 4);
autoL->addWidget(nivLeaderE, 0, 5);
autoL->addWidget(new QLabel(tr("Argent"), autoGroup), 1, 0);
autoL->addWidget(gilsE, 1, 1);
autoL->addWidget(new QLabel(tr("Temps"), autoGroup), 1, 2);
autoL->addWidget(timeE, 1, 3);
autoL->addWidget(new QLabel(tr("Disque"), autoGroup), 1, 4);
autoL->addWidget(discE, 1, 5);
autoL->addWidget(new QLabel(tr("Équipe"), autoGroup), 2, 0);
autoL->addLayout(partyL, 2, 1, 1, 5);
QGridLayout *layout = new QGridLayout(this);
layout->addWidget(previewWidget, 0, 0, 1, 6, Qt::AlignCenter);
layout->addWidget(new QLabel(tr("Lieu affiché")), 1, 0);
layout->addWidget(locationIDE, 1, 1);
layout->addWidget(new QLabel(tr("Nombre de sauvegardes")), 1, 2);
layout->addWidget(saveCountE, 1, 3);
layout->addWidget(new QLabel(tr("Sauvegarde courante")), 1, 4);
layout->addWidget(curSaveE, 1, 5);
layout->addWidget(autoGroup, 2, 0, 1, 6);
layout->setRowStretch(3, 1);
connect(autoGroup, SIGNAL(toggled(bool)), SLOT(setGroupDisabled(bool)));
connect(nivLeaderE, SIGNAL(valueChanged(int)), SLOT(updatePreview()));
connect(gilsE, SIGNAL(valueChanged(double)), SLOT(updatePreview()));
connect(timeE, SIGNAL(valueChanged()), SLOT(updatePreview()));
connect(discE, SIGNAL(valueChanged(double)), SLOT(updatePreview()));
connect(locationIDE, SIGNAL(currentIndexChanged(int)), SLOT(updatePreview()));
foreach(QComboBox *cb, partyE) {
connect(cb, SIGNAL(currentIndexChanged(int)), SLOT(updatePreview()));
}
示例10: createEditor
QWidget* MultiDelegate::createEditor( QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
const QAbstractItemModel* model = index.model();
QVariant value = model->data( index, Qt::EditRole);
switch (value.type()) {
case QMetaType::QTime:
{
QTimeEdit* editor = new QTimeEdit( parent);
editor->setMaximumWidth( editor->sizeHint().width());
//// Get value snapshot into editor
editor->setTime( value.toTime());
return editor;
}
case QMetaType::QDate:
{
QDateEdit* editor = new QDateEdit( parent);
setupCalenderWidget( editor);
editor->setMaximumWidth( editor->sizeHint().width());
//// Get value snapshot into editor
editor->setDate( value.toDate());
return editor;
}
case QMetaType::QDateTime:
{
QDateTimeEdit* editor = new QDateTimeEdit( parent);
setupCalenderWidget( editor);
editor->setMaximumWidth( editor->sizeHint().width());
editor->setDateTime( value.toDateTime());
return editor;
}
case QMetaType::QImage:
// Fall throu
case QMetaType::QPixmap:
// Fall throu
case QMetaType::QIcon:
{
PixmapViewer* editor = new PixmapViewer( parent);
connect( editor, SIGNAL(finished(int)), this, SLOT(closeEmittingEditor()));
return editor;
}
case QMetaType::QStringList:
{
QVariant varList = index.model()->data( index, ItemDataRole::EnumList);
if (varList.isNull()) break; // Not a enum-list, fall to std
QListWidget* editor = new QListWidget( parent);
foreach (const QString& bitItemText, varList.toStringList()) {
QListWidgetItem* bitItem = new QListWidgetItem( bitItemText, editor);
bitItem->setFlags(bitItem->flags() | Qt::ItemIsUserCheckable);
bitItem->setCheckState(Qt::Unchecked);
}
int width = editor->sizeHintForColumn(0) + 25;
int height = editor->sizeHintForRow(0) * editor->count() + 10;
editor->setMinimumWidth( width);
editor->setMaximumWidth( width);
editor->setMinimumHeight( height);
editor->setMaximumHeight( height);
//// Get value snapshot into editor
QStringList valList = value.toStringList();
int itemCount = editor->count();
for (int i = 0; i < itemCount; ++i) {
QListWidgetItem* bitItem = editor->item(i);
bool isActive = valList.contains( bitItem->text());
bitItem->setCheckState( isActive ? Qt::Checked : Qt::Unchecked);
}
return editor;
}
case QMetaType::QString:
{
QVariant varList = index.model()->data( index, ItemDataRole::EnumList);
if (varList.isNull()) break; // Not a enum-list, fall to std
QComboBox* editor = new QComboBox( parent);
editor->setSizeAdjustPolicy(QComboBox::AdjustToContents);
editor->addItems( varList.toStringList());
editor->setMaximumWidth( editor->minimumSizeHint().width());
//// Get value snapshot into editor
editor->setCurrentIndex( editor->findText( value.toString()));
return editor;
}
default:;
}
if (index.column() == 0) {
emit itemEditTrigged( index);
return 0; // No inline editor
}
QWidget* editor = QItemDelegate::createEditor( parent, option, index);
//// Get value snapshot into editor
QItemDelegate::setEditorData( editor, index);
return editor;
//.........这里部分代码省略.........
示例11: open_resolutionDialog
bool QVideoCapture::open_resolutionDialog()
{
if (m_cvCapture.isOpened() && deviceFlag)
{
//GUI CONSTRUCTION//
QDialog dialog;
dialog.setFixedSize(200,180);
dialog.setWindowTitle(tr("Camcorder resolution"));
QVBoxLayout toplevellayout;
toplevellayout.setMargin(5);
QVBoxLayout layout;
layout.setMargin(5);
QGroupBox groupbox;
groupbox.setTitle("Resolution & framerate");
QVBoxLayout comboboxes;
comboboxes.setMargin(5);
QComboBox CBresolution;
CBresolution.addItem("640 x 360"); // 0
CBresolution.addItem("640 x 480"); // 1
CBresolution.addItem("800 x 600"); // 2
CBresolution.addItem("960 x 720"); // 3
CBresolution.addItem("1280 x 720"); // 4
CBresolution.addItem("1920 x 1080"); // 5
CBresolution.setSizeAdjustPolicy(QComboBox::AdjustToContents);
CBresolution.setCurrentIndex(1);
QLabel Lresolution("Set resolution:");
QComboBox CBm_framerate(&dialog);
CBm_framerate.addItem("30 fps"); // 0
CBm_framerate.addItem("25 fps"); // 1
CBm_framerate.addItem("20 fps"); // 2
CBm_framerate.addItem("15 fps"); // 3
CBm_framerate.addItem("60 fps"); // 4
CBm_framerate.setSizeAdjustPolicy(QComboBox::AdjustToContents);
CBm_framerate.setCurrentIndex(0);
QLabel Lm_framerate("Set framerate:");
comboboxes.addWidget(&Lresolution,1,Qt::AlignLeft);
comboboxes.addWidget(&CBresolution);
comboboxes.addWidget(&Lm_framerate,1,Qt::AlignLeft);
comboboxes.addWidget(&CBm_framerate);
groupbox.setLayout(&comboboxes);
layout.addWidget(&groupbox);
QHBoxLayout buttons;
buttons.setMargin(5);
QPushButton Baccept;
Baccept.setText("Accept");
connect(&Baccept, SIGNAL(clicked()), &dialog, SLOT(accept()));
QPushButton Bcancel;
Bcancel.setText("Cancel");
connect(&Bcancel, SIGNAL(clicked()), &dialog, SLOT(reject()));
buttons.addWidget(&Baccept);
buttons.addWidget(&Bcancel);
toplevellayout.addLayout(&layout);
toplevellayout.addLayout(&buttons);
dialog.setLayout(&toplevellayout);
//GUI CONSTRUCTION END//
if(dialog.exec() == QDialog::Accepted)
{
m_cvCapture.set( CV_CAP_PROP_FRAME_WIDTH, CBresolution.itemText(CBresolution.currentIndex()).section(" x ",0,0).toDouble() );
m_cvCapture.set( CV_CAP_PROP_FRAME_HEIGHT, CBresolution.itemText(CBresolution.currentIndex()).section(" x ",1,1).toDouble() );
pt_timer->setInterval( 1000/CBm_framerate.itemText(CBm_framerate.currentIndex()).section(" ",0,0).toDouble() );
}
return true;
}
return false; // will return false if device was not opened or dialog.exec() == QDialog::Rejected
}