本文整理汇总了C++中QComboBox::setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setSizePolicy方法的具体用法?C++ QComboBox::setSizePolicy怎么用?C++ QComboBox::setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setSizePolicy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
MainWindow::MainWindow( QWidget *parent ):
QMainWindow( parent )
{
d_plot = new Plot( this );
setCentralWidget( d_plot );
QToolBar *toolBar = new QToolBar( this );
QComboBox *typeBox = new QComboBox( toolBar );
typeBox->addItem( "Bars" );
typeBox->addItem( "CandleSticks" );
typeBox->setCurrentIndex( 1 );
typeBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
QToolButton *btnExport = new QToolButton( toolBar );
btnExport->setText( "Export" );
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
connect( btnExport, SIGNAL( clicked() ), d_plot, SLOT( exportPlot() ) );
toolBar->addWidget( typeBox );
toolBar->addWidget( btnExport );
addToolBar( toolBar );
d_plot->setMode( typeBox->currentIndex() );
connect( typeBox, SIGNAL( currentIndexChanged( int ) ),
d_plot, SLOT( setMode( int ) ) );
}
示例2: QMainWindow
FlightController::FlightController(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::FlightController), mm(NULL)
{
ui->setupUi(this);
ui->mainPanel->setCurrentIndex(0);
connect(ui->ClearButton, SIGNAL(clicked()), ui->LogViewport, SLOT(clearButtonClick()));
connect(ui->CopyAllButton, SIGNAL(clicked()), ui->LogViewport, SLOT(copyAllButtonClick()));
connect(ui->RedButton, SIGNAL(toggled(bool)), this, SLOT(redButtonToggle(bool)));
connect(ui->BootloaderButton, SIGNAL(clicked()), this, SLOT(bootloaderButtonClick()));
connect(ui->MatrixMonitorButton, SIGNAL(clicked()), this, SLOT(matrixMonitorButtonClick()));
connect(ui->statusRequestButton, SIGNAL(clicked()), this, SLOT(statusRequestButtonClick()));
DeviceInterface &di = Singleton<DeviceInterface>::instance();
di.setLogger(ui->LogViewport);
di.start();
connect(this, SIGNAL(sendCommand(uint8_t,uint8_t)), &di, SLOT(sendCommand(uint8_t, uint8_t)));
ui->ColumnMapping->setLayout(new QHBoxLayout());
for (uint8_t i = 0; i<16; i++)
{
QComboBox *b = new QComboBox();
b->addItem(0, "Skip");
b->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
b->sizeHint().setWidth(0);
ui->ColumnMapping->layout()->addWidget(b);
columns[i] = b;
}
ui->RowMapping->setLayout(new QGridLayout());
}
示例3:
//! [10]
QComboBox *Window::createComboBox(const QString &text) {
QComboBox *comboBox = new QComboBox;
comboBox->setEditable(true);
comboBox->addItem(text);
comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
return comboBox;
}
示例4: QMainWindow
MainWindow::MainWindow( QWidget *parent ):
QMainWindow( parent )
{
d_plot = new Plot( this );
setCentralWidget( d_plot );
QToolBar *toolBar = new QToolBar( this );
#ifndef QT_NO_PRINTER
QToolButton *btnPrint = new QToolButton( toolBar );
btnPrint->setText( "Print" );
btnPrint->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
toolBar->addWidget( btnPrint );
connect( btnPrint, SIGNAL( clicked() ),
d_plot, SLOT( printPlot() ) );
toolBar->addSeparator();
#endif
toolBar->addWidget( new QLabel("Color Map " ) );
QComboBox *mapBox = new QComboBox( toolBar );
mapBox->addItem( "RGB" );
mapBox->addItem( "Indexed Colors" );
mapBox->addItem( "Hue" );
mapBox->addItem( "Alpha" );
mapBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
toolBar->addWidget( mapBox );
connect( mapBox, SIGNAL( currentIndexChanged( int ) ),
d_plot, SLOT( setColorMap( int ) ) );
toolBar->addWidget( new QLabel( " Opacity " ) );
QSlider *slider = new QSlider( Qt::Horizontal );
slider->setRange( 0, 255 );
slider->setValue( 255 );
connect( slider, SIGNAL( valueChanged( int ) ),
d_plot, SLOT( setAlpha( int ) ) );
toolBar->addWidget( slider );
toolBar->addWidget( new QLabel(" " ) );
QCheckBox *btnSpectrogram = new QCheckBox( "Spectrogram", toolBar );
toolBar->addWidget( btnSpectrogram );
connect( btnSpectrogram, SIGNAL( toggled( bool ) ),
d_plot, SLOT( showSpectrogram( bool ) ) );
QCheckBox *btnContour = new QCheckBox( "Contour", toolBar );
toolBar->addWidget( btnContour );
connect( btnContour, SIGNAL( toggled( bool ) ),
d_plot, SLOT( showContour( bool ) ) );
addToolBar( toolBar );
btnSpectrogram->setChecked( true );
btnContour->setChecked( false );
}
示例5: defined
//! [10]
QComboBox *Window::createComboBox(const QString &text)
{
QComboBox *comboBox = new QComboBox;
comboBox->setEditable(true);
comboBox->addItem(text);
comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
comboBox->setMinimumContentsLength(3);
#endif
return comboBox;
}
示例6:
QComboBox *createDirectoryComboBox(const QString &defaultDirectory)
{
QComboBox *comboBox = new QComboBox;
comboBox->addItem(defaultDirectory);
comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
for (const QString &dir : QDir(defaultDirectory).entryList(QDir::AllDirs | QDir::NoDotAndDotDot))
comboBox->addItem(defaultDirectory + "/" +dir);
return comboBox;
}
示例7: addCombo
// Create new combo widget
QtWidgetObject* AtenTreeGuiDialog::addCombo(TreeGuiWidget* widget, QString label)
{
QtWidgetObject* qtwo = widgetObjects_.add();
QComboBox* combo = new QComboBox(this);
qtwo->set(widget, combo, label);
// Add items to combo and set current index
for (int n=0; n<widget->comboItems().count(); ++n) combo->addItem(widget->comboItems().at(n));
combo->setCurrentIndex(widget->valueI() - 1);
combo->setEnabled(widget->enabled());
combo->setVisible(widget->visible());
combo->setMinimumHeight(WIDGETHEIGHT);
combo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// Connect signal to master slot
QObject::connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(comboWidget_currentIndexChanged(int)));
return qtwo;
}
示例8: QLabel
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent, const char *)
: KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
{
QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3;
QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint());
QGrid *grid;
QGroupBox *box;
QLabel *label;
QString strMouseButton1, strMouseButton3, strMouseWheel;
QString txtButton1, txtButton3, txtButton4;
QStringList items;
bool leftHandedMouse = (KGlobalSettings::mouseSettings().handed == KGlobalSettings::KMouseSettings::LeftHanded);
/** Titlebar doubleclick ************/
QHBoxLayout *hlayout = new QHBoxLayout(layout);
label = new QLabel(i18n("&Titlebar double-click:"), this);
hlayout->addWidget(label);
QWhatsThis::add(label, i18n("Here you can customize mouse click behavior when double clicking on the"
" titlebar of a window."));
QComboBox *combo = new QComboBox(this);
combo->insertItem(i18n("Maximize"));
combo->insertItem(i18n("Maximize (vertical only)"));
combo->insertItem(i18n("Maximize (horizontal only)"));
combo->insertItem(i18n("Minimize"));
combo->insertItem(i18n("Shade"));
combo->insertItem(i18n("Lower"));
combo->insertItem(i18n("On All Desktops"));
combo->insertItem(i18n("Nothing"));
combo->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
connect(combo, SIGNAL(activated(int)), SLOT(changed()));
hlayout->addWidget(combo);
coTiDbl = combo;
QWhatsThis::add(combo, i18n("Behavior on <em>double</em> click into the titlebar."));
label->setBuddy(combo);
/** Mouse Wheel Events **************/
QHBoxLayout *hlayoutW = new QHBoxLayout(layout);
strMouseWheel = i18n("Titlebar wheel event:");
label = new QLabel(strMouseWheel, this);
hlayoutW->addWidget(label);
txtButton4 = i18n("Handle mouse wheel events");
QWhatsThis::add(label, txtButton4);
// Titlebar and frame mouse Wheel
QComboBox *comboW = new QComboBox(this);
comboW->insertItem(i18n("Raise/Lower"));
comboW->insertItem(i18n("Shade/Unshade"));
comboW->insertItem(i18n("Maximize/Restore"));
comboW->insertItem(i18n("Keep Above/Below"));
comboW->insertItem(i18n("Move to Previous/Next Desktop"));
comboW->insertItem(i18n("Change Opacity"));
comboW->insertItem(i18n("Nothing"));
comboW->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
connect(comboW, SIGNAL(activated(int)), SLOT(changed()));
hlayoutW->addWidget(comboW);
coTiAct4 = comboW;
QWhatsThis::add(comboW, txtButton4);
label->setBuddy(comboW);
/** Titlebar and frame **************/
box = new QVGroupBox(i18n("Titlebar && Frame"), this, "Titlebar and Frame");
box->layout()->setMargin(KDialog::marginHint());
box->layout()->setSpacing(KDialog::spacingHint());
layout->addWidget(box);
QWhatsThis::add(box, i18n("Here you can customize mouse click behavior when clicking on the"
" titlebar or the frame of a window."));
grid = new QGrid(4, Qt::Vertical, box);
new QLabel(grid); // dummy
strMouseButton1 = i18n("Left button:");
txtButton1 = i18n(
"In this row you can customize left click behavior when clicking into"
" the titlebar or the frame.");
strMouseButton3 = i18n("Right button:");
txtButton3 = i18n(
"In this row you can customize right click behavior when clicking into"
" the titlebar or the frame.");
if(leftHandedMouse)
{
qSwap(strMouseButton1, strMouseButton3);
qSwap(txtButton1, txtButton3);
}
label = new QLabel(strMouseButton1, grid);
QWhatsThis::add(label, txtButton1);
label = new QLabel(i18n("Middle button:"), grid);
QWhatsThis::add(label, i18n("In this row you can customize middle click behavior when clicking into"
" the titlebar or the frame."));
//.........这里部分代码省略.........
示例9: 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;
}
示例10: grBtoY
scannerwindow::scannerwindow(QList<int> parameters, QMainWindow *parent, bool load, QTextStream* stream):
QObject(parent)
{
this->parameters=parameters;
widget = new QWidget();
widget->setAttribute(Qt::WA_DeleteOnClose);
graph = new Q3DSurface();
container = QWidget::createWindowContainer(graph, widget);
container->setAttribute(Qt::WA_AcceptTouchEvents);
widget->setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignTop,
widget->size(),
qApp->desktop()->availableGeometry()
)
);
bitmapForward=new QCustomPlot(widget);
bitmapBackward=new QCustomPlot(widget);
bitmapCombined=new QCustomPlot(widget);
bitmapForward->setContextMenuPolicy(Qt::CustomContextMenu);
bitmapBackward->setContextMenuPolicy(Qt::CustomContextMenu);
bitmapCombined->setContextMenuPolicy(Qt::CustomContextMenu);
bitmapBackward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
bitmapForward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
bitmapCombined->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
initializeBitmapForward(bitmapForward);
initializeBitmapBackward(bitmapBackward);
initializeBitmapCombined(bitmapCombined);
if (!graph->hasContext()) {
QMessageBox msgBox;
msgBox.setText("Couldn't initialize the OpenGL context.");
msgBox.exec();
}
QSize screenSize = graph->screen()->size();
container->setMinimumSize(QSize(screenSize.width() / 3, screenSize.height()/4));
container->setMaximumSize(screenSize);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
container->setFocusPolicy(Qt::StrongFocus);
bitmapBackward->setMinimumSize(screenSize.width()/4, screenSize.height()/4);
bitmapForward->setMinimumSize(screenSize.width()/4, screenSize.height()/4);
bitmapCombined->setMinimumSize(screenSize.width()/4, screenSize.height()/4);
QHBoxLayout *hLayout = new QHBoxLayout(widget);
QVBoxLayout *vLayout = new QVBoxLayout();
QSplitter *hSplitterMain = new QSplitter();
QSplitter *vSplitterRight = new QSplitter();
hLayout->setSizeConstraint(QBoxLayout::SizeConstraint::SetMinimumSize);
vSplitterRight->addWidget(bitmapForward);
vSplitterRight->addWidget(bitmapBackward);
vSplitterRight->addWidget(bitmapCombined);
vSplitterRight->setOrientation(Qt::Orientation::Vertical);
vSplitterRight->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
hSplitterMain->setOrientation(Qt::Orientation::Horizontal);
hSplitterMain->addWidget(container);
hSplitterMain->addWidget(vSplitterRight);
hSplitterMain->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}");
vSplitterRight->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}");
hLayout->addWidget(hSplitterMain);
hLayout->addLayout(vLayout);
vLayout->setAlignment(Qt::AlignTop);
widget->setWindowTitle(QStringLiteral("AFM Scan"));
QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Scan"));
if(!load){
AFM_Scan_3D_RB = new QPushButton(widget);
AFM_Scan_3D_RB->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
AFM_Scan_3D_RB->setText(QStringLiteral("Start Scan"));
AFM_Scan_3D_RB->setCheckable(true);
AFM_Scan_3D_RB->setChecked(false);
}
SaveSurface = new QPushButton(widget);
SaveSurface->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
SaveSurface->setText(QStringLiteral("Save Data"));
BitmapView = new QPushButton(widget);
BitmapView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
//.........这里部分代码省略.........