本文整理汇总了C++中QComboBox::setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setMaximumWidth方法的具体用法?C++ QComboBox::setMaximumWidth怎么用?C++ QComboBox::setMaximumWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setMaximumWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)));
}
示例2: 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;
//.........这里部分代码省略.........