本文整理汇总了C++中QComboBox::setMinimumWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setMinimumWidth方法的具体用法?C++ QComboBox::setMinimumWidth怎么用?C++ QComboBox::setMinimumWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setMinimumWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectExtraInfo
bool Ruler::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
bool result = PaletteItem::collectExtraInfo(parent, family, prop, value, swappingEnabled, returnProp, returnValue, returnWidget);
if (prop.compare("width", Qt::CaseInsensitive) == 0) {
returnProp = tr("width");
int units = m_modelPart->localProp("width").toString().contains("cm") ? IndexCm : IndexIn;
QLineEdit * e1 = new QLineEdit();
QDoubleValidator * validator = new QDoubleValidator(e1);
validator->setRange(1.0, 20 * ((units == IndexCm) ? 2.54 : 1), 2);
validator->setNotation(QDoubleValidator::StandardNotation);
e1->setValidator(validator);
e1->setEnabled(swappingEnabled);
QString temp = m_modelPart->localProp("width").toString();
temp.chop(2);
e1->setText(temp);
e1->setObjectName("infoViewLineEdit");
e1->setMaximumWidth(80);
m_widthEditor = e1;
m_widthValidator = validator;
QComboBox * comboBox = new QComboBox(parent);
comboBox->setEditable(false);
comboBox->setEnabled(swappingEnabled);
comboBox->addItem("cm");
comboBox->addItem("in");
comboBox->setCurrentIndex(units);
m_unitsEditor = comboBox;
comboBox->setObjectName("infoViewComboBox");
comboBox->setMinimumWidth(60);
QHBoxLayout * hboxLayout = new QHBoxLayout();
hboxLayout->setAlignment(Qt::AlignLeft);
hboxLayout->setContentsMargins(0, 0, 0, 0);
hboxLayout->setSpacing(0);
hboxLayout->setMargin(0);
hboxLayout->addWidget(e1);
hboxLayout->addWidget(comboBox);
QFrame * frame = new QFrame();
frame->setLayout(hboxLayout);
frame->setObjectName("infoViewPartFrame");
connect(e1, SIGNAL(editingFinished()), this, SLOT(widthEntry()));
connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(unitsEntry(const QString &)));
returnValue = temp + QString::number(units);
returnWidget = frame;
return true;
}
示例2: QComboBox
QWidget *ComponentAction::createWidget(QWidget *parent)
{
QComboBox *comboBox = new QComboBox(parent);
comboBox->setMinimumWidth(120);
comboBox->setToolTip(tr("Edit sub components defined in this file"));
comboBox->setModel(m_componentView->standardItemModel());
comboBox->setCurrentIndex(-1);
connect(comboBox, SIGNAL(activated(int)), SLOT(emitCurrentComponentChanged(int)));
connect(this, SIGNAL(currentIndexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
return comboBox;
}
示例3: createAddressingBox
inline QComboBox* createAddressingBox( void )
{
QComboBox *addrSelect = new QComboBox();
for ( const addrToNatural& item : addrToNaturalList )
{
addrSelect->addItem( item.natural );
}
addrSelect->setMinimumWidth( 200 );
return addrSelect;
}
示例4: on_AddExpenseButton_clicked
void EntryEditorDialog::on_AddExpenseButton_clicked()
{
//TODO refactor
QHBoxLayout *newLayout = new QHBoxLayout();
QComboBox *entryName = new QComboBox();
newLayout->addWidget(entryName);
entryName->setEditable(true);
entryName->setMinimumWidth(150);
newLayout->addStretch();
QLineEdit *entryAmount = new QLineEdit();
newLayout->addWidget(entryAmount);
entryAmount->setMinimumWidth(100);
entryAmount->setAlignment(Qt::AlignRight);
ui->ExpenseEntryLayout->addLayout(newLayout);
}
示例5: addbutton_clicked
void ConfigStation::addbutton_clicked()
{
QHBoxLayout *hlayout =new QHBoxLayout;
QLineEdit *stale = new QLineEdit;
QComboBox *chancb = new QComboBox;
QComboBox *compcb = new QComboBox;
QLineEdit *locle = new QLineEdit;
locle->setEnabled(false);
QLineEdit *netle = new QLineEdit;
QLineEdit *latle = new QLineEdit;
QLineEdit *lonle = new QLineEdit;
QLineEdit *elevle = new QLineEdit;
qlist.push_back(stale);
sta.resize(qlist.count()); chan.resize(qlist.count()); comp.resize(qlist.count()); loc.resize(qlist.count()); net.resize(qlist.count());
lat.resize(qlist.count()); lon.resize(qlist.count()); elev.resize(qlist.count());
chan[qlist.count()-1] = "HG";
comp[qlist.count()-1] = "Z";
loc[qlist.count()-1] = "--";
int i=0;
stale->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
chancb->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
compcb->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
locle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
netle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
latle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
lonle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
elevle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) );
stale->setAlignment(Qt::AlignCenter);
locle->setAlignment(Qt::AlignCenter);
netle->setAlignment(Qt::AlignCenter);
latle->setAlignment(Qt::AlignCenter);
lonle->setAlignment(Qt::AlignCenter);
elevle->setAlignment(Qt::AlignCenter);
locle->setText("--");
QStringList chan;
chan << "HG" << "BG" << "HH" << "BH" << "EL" << "SL";
chancb->addItems(chan); chancb->setCurrentIndex(0);
QStringList comp;
comp << "Z" << "N" << "E" << "Z/N/E" << "N/E";
compcb->addItems(comp); compcb->setCurrentIndex(0);
hlayout->addWidget(stale);
hlayout->addWidget(chancb);
hlayout->addWidget(compcb);
hlayout->addWidget(locle);
hlayout->addWidget(netle);
hlayout->addWidget(latle);
hlayout->addWidget(lonle);
hlayout->addWidget(elevle);
chancb->setMaximumWidth(130);
chancb->setMinimumWidth(130);
compcb->setMaximumWidth(130);
compcb->setMinimumWidth(130);
middlelayout->addLayout(hlayout);
connect(stale, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(chancb, SIGNAL(currentIndexChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(compcb, SIGNAL(currentIndexChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(locle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(netle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(latle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(lonle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
connect(elevle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
}
示例6: updateModels
void ModelMgrWidget::updateModels()
{
//
QLayoutItem *child;
while (child = q_horiLayoutMain->takeAt(0)) {
QWidget *widget = child->widget();
if (widget) {
widget->setParent(0);
widget->deleteLater();
}
delete child;
}
//
IconButton *buttonHome = new IconButton(QPixmap(":/application/image/home-1.png"), this);
buttonHome->setObjectName("buttonHome");
buttonHome->setFixedSize(25, 25);
buttonHome->setToolTip(QStringLiteral("主页"));
q_horiLayoutMain->addWidget(buttonHome);
QComboBox *comboBoxModel = new QComboBox(this);
comboBoxModel->addItem(QStringLiteral("数据管理"));
comboBoxModel->addItem(QStringLiteral("数据查询"));
comboBoxModel->addItem(QStringLiteral("数据分析"));
comboBoxModel->setMinimumWidth(QFontMetrics(comboBoxModel->font())
.width(comboBoxModel->itemText(0)) + 50);
comboBoxModel->setToolTip(QStringLiteral("只切换模式界面,不初始化界面数据"));
q_horiLayoutMain->addWidget(comboBoxModel);
//
connect(buttonHome, &QPushButton::clicked, [=](bool){
setCurrentModel(QStringLiteral("数据管理"));
});
//
QStringListIterator citerModelStack(q_modelStack);
while (citerModelStack.hasNext()) {
const QString &model = citerModelStack.next();
//
JClickableLabel *labelName = new JClickableLabel(model, this);
labelName->setObjectName("labelName");
labelName->setAlignment(Qt::AlignVCenter);
labelName->setText(model);
IconButton *buttonArrow = new IconButton(QPixmap(":/application/image/arrow-1.png"), this);
buttonArrow->setObjectName("buttonArrow");
buttonArrow->setFixedSize(20, 25);
q_horiLayoutMain->addWidget(labelName);
q_horiLayoutMain->addWidget(buttonArrow);
//
connect(labelName, &JClickableLabel::clicked, [=](){
setCurrentModel(labelName->text());
});
}
//
comboBoxModel->setCurrentText(q_modelStack.last());
//
connect(comboBoxModel, &QComboBox::currentTextChanged, [=](const QString &text){
setCurrentModel(text, false);
Q_EMIT currentIndexChanged(text);
});
}
示例7: QComboBox
QWidget * MTPageNym_AltLocation::createSingleContactItem(GroupBoxContactItems * pGroupBox, int nComboIndex/*=0*/,
const QString textValue/*=""*/, const bool bIsPrimary/*=false*/)
{
QWidget * pWidgetContactItem = new QWidget;
// ----------------------------------------------------------
QComboBox * pComboType = new QComboBox(pWidgetContactItem);
QLineEdit * pLineEditItemValue = new QLineEdit(pWidgetContactItem);
QPushButton * pBtnDelete = new QPushButton(tr("Delete"), pWidgetContactItem);
QRadioButton * pBtnRadio = new QRadioButton(tr("Primary"), pWidgetContactItem);
pGroupBox->addRadioButton(pBtnRadio);
// ----------------------------------------------------------
pComboType->setMinimumWidth(60);
pComboType->setMinimumHeight(25);
pComboType->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
pBtnDelete->setMinimumHeight(25);
pBtnDelete->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
pLineEditItemValue->setMinimumWidth(55);
pLineEditItemValue->setMinimumHeight(25);
pLineEditItemValue->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// ----------------------------------------------------------
pWidgetContactItem->setProperty("groupbox", VPtr<GroupBoxContactItems>::asQVariant(pGroupBox));
pWidgetContactItem->setProperty("combo", VPtr<QComboBox>::asQVariant(pComboType));
pWidgetContactItem->setProperty("lineedit", VPtr<QLineEdit>::asQVariant(pLineEditItemValue));
pWidgetContactItem->setProperty("deletebtn", VPtr<QPushButton>::asQVariant(pBtnDelete));
pWidgetContactItem->setProperty("radiobtn", VPtr<QRadioButton>::asQVariant(pBtnRadio));
// ----------------------------------------------------------
pComboType ->setProperty("contactitemwidget", VPtr<QWidget>::asQVariant(pWidgetContactItem));
pLineEditItemValue->setProperty("contactitemwidget", VPtr<QWidget>::asQVariant(pWidgetContactItem));
pBtnDelete ->setProperty("contactitemwidget", VPtr<QWidget>::asQVariant(pWidgetContactItem));
pBtnRadio ->setProperty("contactitemwidget", VPtr<QWidget>::asQVariant(pWidgetContactItem));
// ---------------------------------------------------------
// pBtnDelete->setMinimumWidth(60);
// pBtnDelete->setProperty("contactSection", contactSection);
// pBtnDelete->setProperty("contactSectionType", contactSectionType);
// ----------------------------------------------------------
for (QMap<uint32_t, QString>::iterator it_types = pGroupBox->mapTypeNames_.begin();
it_types != pGroupBox->mapTypeNames_.end();
++it_types)
{
const uint32_t & key = it_types.key(); // section type ID
const QString & value = it_types.value(); // section type name
pComboType->addItem(value, QVariant::fromValue(key));
}
// ----------------------------------------------------------
// We don't set this until here, underneath the above loop.
// After all, you can't set the combo box to a certain current index
// if you haven't even populated it yet!
//
pBtnRadio->setChecked(bIsPrimary);
pComboType->setCurrentIndex(nComboIndex);
pLineEditItemValue->setText(textValue);
// ----------------------------------------------------------
QHBoxLayout *layout = new QHBoxLayout(pWidgetContactItem);
layout->setMargin(0);
layout->addWidget(pComboType);
layout->addWidget(pLineEditItemValue);
layout->addWidget(pBtnRadio);
layout->addWidget(pBtnDelete);
// ----------------------------------------------------------
pWidgetContactItem->setLayout(layout);
connect(pComboType, SIGNAL(currentIndexChanged(int)), this, SLOT(on_comboBox_currentIndexChanged(int)) );
connect(pBtnDelete, SIGNAL(clicked()), this, SLOT(on_btnContactItemDelete_clicked()));
connect(pLineEditItemValue, SIGNAL(textChanged(QString)), this, SLOT(on_lineEditItemValue_textChanged(QString)));
connect(pBtnRadio, SIGNAL(toggled(bool)), this, SLOT(on_btnPrimary_toggled(bool)));
// connect(this, SIGNAL(initialNameProfileSetting(QString)), pLineEditItemValue, SIGNAL(textChanged(QString)));
// ----------------------------------------------------------
// layout->setStretch(0, 0);
// layout->setStretch(1, -1);
// layout->setStretch(2, 0);
// ----------------------------------------------------------
return pWidgetContactItem;
}