本文整理汇总了C++中QSizePolicy::setHorizontalPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::setHorizontalPolicy方法的具体用法?C++ QSizePolicy::setHorizontalPolicy怎么用?C++ QSizePolicy::setHorizontalPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::setHorizontalPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildGUI
QWidget* QCamAutoAlign::buildGUI(QWidget * parent) {
QSizePolicy sizePolicyMax;
sizePolicyMax.setVerticalPolicy(QSizePolicy::Expanding);
sizePolicyMax.setHorizontalPolicy(QSizePolicy::Expanding);
QSizePolicy sizePolicyMin;
sizePolicyMin.setVerticalPolicy(QSizePolicy::Minimum);
sizePolicyMin.setHorizontalPolicy(QSizePolicy::Minimum);
QWidget* remoteCTRL= QCam::buildGUI(parent);
QCamUtilities::registerWidget(remoteCTRL);
QPushButton* resetCenter = new QPushButton(tr("reset"),remoteCTRL);
connect(resetCenter,SIGNAL(pressed()),this,SLOT(reset()));
findShiftWidget_=new QCamHGroupBox(tr("Find Shift Ctrl"),remoteCTRL);
if (tracker_) {
findShiftCtrl_=tracker_->buildGUI(findShiftWidget_);
}
cropSlider_=new QCamSlider(tr("crop"),false,remoteCTRL,1,100);
cropSlider_->setSizePolicy(sizePolicyMin);
connect(cropSlider_, SIGNAL(valueChange(int)),
this,SLOT(setCropValue(int)));
cropSlider_->setValue((int)round(cropValue_*100));
cropSlider_->setToolTip(tr("% of image to keep when crooping"));
centerButton_=new QCheckBox(tr("Center image"),remoteCTRL);
connect(centerButton_,SIGNAL(toggled(bool)),this,SLOT(setImageCenter(bool)));
centerButton_->setToolTip(tr("Center shifted images on the center of the frame"));
#if ONE_MAP
scaleSlider_=new QCamSlider(tr("Display scale"),false,remoteCTRL,1,100);
scaleSlider_->setSizePolicy(sizePolicyMin);
scaleSlider_->setToolTip(tr("Scale of the shift history Map"));
shiftMap_= new QVectorMap(remoteCTRL);
shiftMap_->setSizePolicy(sizePolicyMax);
shiftMap_->setMode(DrawLine);
connect(scaleSlider_, SIGNAL(valueChange(int)),shiftMap_,SLOT(setScale(int)));
shiftMap_->setToolTip(tr("Show the history of the frame shift"));
#else
shiftXhisto_ = new QHistogram(remoteCTRL);
shiftXhisto_->setDataSize(200);
shiftXhisto_->setAutoShift(true);
shiftXhisto_->setAverage(4);
shiftYhisto_ = new QHistogram(remoteCTRL);
shiftYhisto_->setDataSize(200);
shiftYhisto_->setAutoShift(true);
shiftYhisto_->setAverage(4);
#endif
resetCenter->show();
return remoteCTRL;
}
示例2: myPalette
ChatWidget::ChatWidget(QWidget *parent) : QScrollArea(parent), ui(new Ui::ChatWidget) {
ui->setupUi(this);
this->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
QSizePolicy selfSizePolicy = this->sizePolicy();
selfSizePolicy.setHeightForWidth(true);
this->setSizePolicy(selfSizePolicy);
this->setWidgetResizable(true);
QSizePolicy contentsSizePolicy = ui->scrollAreaWidgetContents->sizePolicy();
contentsSizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
contentsSizePolicy.setVerticalPolicy(QSizePolicy::Expanding);
contentsSizePolicy.setHeightForWidth(true);
ui->scrollAreaWidgetContents->setSizePolicy(contentsSizePolicy);
ui->scrollAreaWidgetContents->setMinimumWidth(400);
this->setWidget(ui->scrollAreaWidgetContents);
topLayout = new QVBoxLayout();
ui->scrollAreaWidgetContents->setLayout(topLayout);
QPalette myPalette(palette());
myPalette.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
this->setPalette(myPalette);
}
示例3: fm
MyInputDialog::MyInputDialog(const char * title, const QString & msg,
const QStringList & list, const QString & init,
bool existing)
: QDialog(0/*, title, TRUE*/), le(0)
{
setWindowTitle(title);
move(QCursor::pos());
QVBoxLayout * vbox = new QVBoxLayout(this);
QHBoxLayout * hbox;
vbox->setMargin(5);
hbox = new QHBoxLayout();
vbox->addLayout(hbox);
hbox->setMargin(5);
hbox->addWidget(new QLabel(msg, this));
cb = new QComboBox(this);
cb->setEditable(!existing);
if (! existing)
cb->addItem(init);
cb->addItems(list);
if (! existing) {
cb->setCurrentIndex(0);
cb->setAutoCompletion(completion());
}
hbox->addWidget(cb);
QSizePolicy sp = cb->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Expanding);
cb->setSizePolicy(sp);
QFontMetrics fm(QApplication::font());
cb->setMinimumWidth(fm.width("azertyuiopqsdfghjklm"));
hbox = new QHBoxLayout();
vbox->addLayout(hbox);
hbox->setMargin(5);
QPushButton * ok = new QPushButton(tr("&OK"), this);
QPushButton * cancel = new QPushButton(tr("&Cancel"), this);
QSize bs(cancel->sizeHint());
ok->setDefault(TRUE);
ok->setFixedSize(bs);
cancel->setFixedSize(bs);
hbox->addWidget(ok);
hbox->addWidget(cancel);
connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
cb->setFocus();
}
示例4: createToolBar
void GLSLTextEditorWidget::createToolBar(GLSLEditorEditable *editable)
{
m_outlineCombo = new QComboBox;
m_outlineCombo->setMinimumContentsLength(22);
// ### m_outlineCombo->setModel(m_outlineModel);
QTreeView *treeView = new QTreeView;
treeView->header()->hide();
treeView->setItemsExpandable(false);
treeView->setRootIsDecorated(false);
m_outlineCombo->setView(treeView);
treeView->expandAll();
//m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
// Make the combo box prefer to expand
QSizePolicy policy = m_outlineCombo->sizePolicy();
policy.setHorizontalPolicy(QSizePolicy::Expanding);
m_outlineCombo->setSizePolicy(policy);
QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());
QList<QAction*> actions = toolBar->actions();
toolBar->insertWidget(actions.first(), m_outlineCombo);
}
示例5: QMainWindow
pictoController::pictoController(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::pictoController){
ui->setupUi(this);
subwidget = new subWidget();
subwidget->setWindowTitle("subWidget");
QSizePolicy policy;
policy.setVerticalPolicy(QSizePolicy::Fixed);
policy.setHorizontalPolicy(QSizePolicy::Fixed);
subwidget->setSizePolicy(policy);
subwidget->setFixedSize(385,216);
ui->gridLayout_3->addWidget(subwidget, 0, 2, 1, 1);
move(1300,0);
//preset tab settings
ui->tableWidget->setColumnWidth(0, 300);
QFont font;
font.setPointSize(7);
font.setFamily("MS UI Gothic");
font.setBold(true);
ui->tableWidget->horizontalHeader()->setFont(font);
//ui->tableWidget->horizontalHeaderItem(1)->setFlags(Qt::ItemFlag::);
}
示例6: setup_ui
void EditorMultiLineInputDialog::setup_ui()
{
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
sizePolicy.setVerticalPolicy(QSizePolicy::Expanding);
textArea=new QTextEdit(this);
textArea->setAcceptRichText(false);
textArea->setSizePolicy(sizePolicy);
buttonBox=new QDialogButtonBox(Qt::Horizontal);
buttonBox->addButton(tr("OK"),QDialogButtonBox::AcceptRole);
buttonBox->addButton(tr("Cancel"),QDialogButtonBox::RejectRole);
// Устанавливается размер окна, равныи виджету, из которого
// этот виджет был вызван
if(this->parent()->isWidgetType())
{
QWidget *parentWidget=qobject_cast<QWidget *>(this->parent());
QRect geom(parentWidget->pos(), parentWidget->size());
qDebug() << "Parent window geometry " << geom.x() << geom.y() << geom.width() << geom.height();
setMinimumSize(parentWidget->size());
}
}
示例7: QWidget
Tab::Tab(QWidget* parent):
QWidget(parent),
m_Page(new Page(this))
{
QSizePolicy sp;
sp.setHorizontalPolicy(QSizePolicy::Maximum);
m_Page->headersArea().get()->setFixedHeight(70);
m_Page->linksArea().get()->setFixedHeight(100);
//m_Page->headersArea().get()->setSizePolicy(sp);
//m_Page->headersArea().get()->setSizeAdjustPolicy();
m_Page->headersArea().get()->setReadOnly(true);
m_Page->linksArea().get()->setReadOnly(true);
m_Page->bodyArea().get()->setReadOnly(true);
m_VertLayout.reset(new QVBoxLayout(this));
m_VertLayout->addWidget(m_Page->headersArea().get());
m_VertLayout->addWidget(m_Page->linksArea().get());
m_VertLayout->addWidget(m_Page->bodyArea().get());
setLayout(m_VertLayout.get());
QObject::connect(this, SIGNAL(needReloadPage()), this, SLOT(reloadPage()));
}
示例8: smartMaxSize
void tst_QLayout::smartMaxSize()
{
QVector<int> expectedWidths;
QFile f(QFINDTESTDATA("baseline/smartmaxsize"));
QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Text), true);
QTextStream stream(&f);
while(!stream.atEnd()) {
QString line = stream.readLine(200);
expectedWidths.append(line.section(QLatin1Char(' '), 6, -1, QString::SectionSkipEmpty).toInt());
}
f.close();
int sizeCombinations[] = { 0, 10, 20, QWIDGETSIZE_MAX};
QSizePolicy::Policy policies[] = { QSizePolicy::Fixed,
QSizePolicy::Minimum,
QSizePolicy::Maximum,
QSizePolicy::Preferred,
QSizePolicy::Expanding,
QSizePolicy::MinimumExpanding,
QSizePolicy::Ignored
};
Qt::Alignment alignments[] = { 0,
Qt::AlignLeft,
Qt::AlignRight,
Qt::AlignHCenter
};
int expectedIndex = 0;
int regressionCount = 0;
for (size_t p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(policies[p]);
for (size_t min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
int minSize = sizeCombinations[min];
for (size_t max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
int maxSize = sizeCombinations[max];
for (size_t sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
int sizeHint = sizeCombinations[sh];
for (size_t a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
Qt::Alignment align = alignments[a];
QSize sz = qSmartMaxSize(QSize(sizeHint, 1), QSize(minSize, 1), QSize(maxSize, 1), sizePolicy, align);
int width = sz.width();
int expectedWidth = expectedWidths[expectedIndex];
if (width != expectedWidth) {
qDebug() << "error at index" << expectedIndex << ":" << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
++regressionCount;
}
++expectedIndex;
}
}
}
}
}
QCOMPARE(regressionCount, 0);
}
示例9: init_uml_tab
void ComponentDialog::init_uml_tab()
{
bool visit = !hasOkButton();
BrowserComponent * bn = (BrowserComponent *) data->get_browser_node();
VVBox * vbox;
GridBox * grid = new GridBox(2, this);
umltab = grid;
grid->setMargin(5);
grid->setSpacing(5);
grid->addWidget(new QLabel(tr("name : "), grid));
grid->addWidget(edname = new LineEdit(bn->get_name(), grid));
edname->setReadOnly(visit);
grid->addWidget(new QLabel(tr("stereotype : "), grid));
grid->addWidget(edstereotype = new QComboBox(grid));
edstereotype->setEditable(true);
edstereotype->addItem(toUnicode(data->get_stereotype()));
if (! visit) {
edstereotype->addItems(BrowserComponent::default_stereotypes());
edstereotype->addItems(ProfiledStereotypes::defaults(UmlComponent));
edstereotype->setAutoCompletion(completion());
}
edstereotype->setCurrentIndex(0);
QSizePolicy sp = edstereotype->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Expanding);
edstereotype->setSizePolicy(sp);
grid->addWidget(vbox = new VVBox(grid));
vbox->addWidget(new QLabel(tr("description :"), vbox));
if (! visit)
{
SmallPushButton* sButton;
connect(sButton = new SmallPushButton(tr("Editor"), vbox), SIGNAL(clicked()),
this, SLOT(edit_description()));
vbox->addWidget(sButton);
}
grid->addWidget(comment = new MultiLineEdit(grid));
comment->setReadOnly(visit);
comment->setText(bn->get_comment());
QFont font = comment->font();
if (! hasCodec())
font.setFamily("Courier");
font.setFixedPitch(TRUE);
comment->setFont(font);
addTab(grid, "Uml");
}
示例10: init_l_tab
void ComponentDialog::init_l_tab(VVBox *& page, QComboBox *& stereotypefilter,
void (ComponentDialog::* filteractivated)(const QString & st),
const char * slt,
const char * add_slt, const char * remove_slt,
QListWidget *& lb_available, QListWidget *& lb,
const QList<BrowserClass *> & cls,
QString lbl)
{
bool visit = !hasOkButton();
HHBox * hbox;
VVBox * vbox;
QPushButton * button;
QLabel* label;
page = new VVBox(this);
if (!visit) {
page->addWidget(hbox = new HHBox(page));
hbox->setMargin(5);
hbox->addWidget(new QLabel(tr("Stereotype filtering "), hbox));
hbox->addWidget(stereotypefilter = new QComboBox(hbox));
stereotypefilter->setEditable(true);
stereotypefilter->setAutoCompletion(completion());
stereotypefilter->addItem("");
stereotypefilter->addItems(BrowserClass::default_stereotypes());
stereotypefilter->addItems(ProfiledStereotypes::defaults(UmlComponent));
stereotypefilter->setCurrentIndex(0);
QSizePolicy sp = stereotypefilter->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Expanding);
stereotypefilter->setSizePolicy(sp);
connect(stereotypefilter, SIGNAL(activated(const QString &)),
this, slt);
page->addWidget(hbox = new HHBox(page));
hbox->addWidget(vbox = new VVBox(hbox));
vbox->setMargin(5);
(label = new QLabel(tr("Available classes"), vbox))->setAlignment(Qt::AlignCenter);
vbox->addWidget(label);
vbox->addWidget(lb_available = new QListWidget(vbox));
lb_available->setSelectionMode(QListWidget::MultiSelection);
hbox->addWidget(vbox = new VVBox(hbox));
vbox->setMargin(5);
(label = new QLabel("", vbox))->setScaledContents(TRUE);
vbox->addWidget(label);
vbox->addWidget(button = new QPushButton(vbox));
button->setIcon(*rightPixmap);
connect(button, SIGNAL(clicked()), this, add_slt);
(label = new QLabel("", vbox))->setScaledContents(TRUE);
vbox->addWidget(label);
vbox->addWidget(button = new QPushButton(vbox));
button->setIcon(*leftPixmap);
connect(button, SIGNAL(clicked()), this, remove_slt);
(label = new QLabel("", vbox))->setScaledContents(TRUE);
vbox->addWidget(label);
hbox->addWidget(vbox = new VVBox(hbox));
}
示例11: setWidget
/*!
Sets the \a widget to show below the progress bar.
This will be destroyed when the progress indicator is destroyed.
Default is to show no widget below the progress indicator.
*/
void FutureProgress::setWidget(QWidget *widget)
{
delete d->m_widget;
QSizePolicy sp = widget->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Ignored);
widget->setSizePolicy(sp);
d->m_widget = widget;
if (d->m_widget)
d->m_widgetLayout->addWidget(d->m_widget);
}
示例12: SetWidget
void TFutureProgress::SetWidget(QWidget *Widget)
{
Q_D(TFutureProgress);
delete d->Widget;
QSizePolicy sp = Widget->sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Ignored);
Widget->setSizePolicy(sp);
d->Widget = Widget;
if(d->Widget)
d->WidgetLayout->addWidget(d->Widget);
}
示例13: VcsBaseEditor
VcsBaseDiffEditor::VcsBaseDiffEditor(VcsBaseEditorWidget *w, const VcsBaseEditorParameters *type) :
VcsBaseEditor(w, type),
m_diffFileBrowseComboBox(new QComboBox)
{
m_diffFileBrowseComboBox->setMinimumContentsLength(20);
// Make the combo box prefer to expand
QSizePolicy policy = m_diffFileBrowseComboBox->sizePolicy();
policy.setHorizontalPolicy(QSizePolicy::Expanding);
m_diffFileBrowseComboBox->setSizePolicy(policy);
insertExtraToolBarWidget(Left, m_diffFileBrowseComboBox);
}
示例14: QWidget
QRcodeWidget::QRcodeWidget(QWidget *parent) :
QWidget(parent)
{
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(QSizePolicy::Fixed);
sizePolicy.setVerticalPolicy(QSizePolicy::Fixed);
this->setSizePolicy(sizePolicy);
this->resize(QSize(200, 200));
this->setMinimumSize(this->size());
code = NULL;
}
示例15: updateParts
void QtnPropertyWidget::updateParts()
{
// clear layout
while (!m_layout->isEmpty())
m_layout->takeAt(0);
// check toolbar
// check description panel
if (m_parts & QtnPropertyWidgetPartsDescriptionPanel)
{
if (!m_descriptionSplitter)
{
// create splitter
Q_ASSERT(!m_descriptionPanel);
QSplitter* splitter = new QSplitter(Qt::Vertical, this);
// add property view
splitter->addWidget(m_propertyView);
// create description panel
m_descriptionPanel = new QLabel(splitter);
m_descriptionPanel->setTextFormat(Qt::RichText);
m_descriptionPanel->setAlignment(Qt::AlignTop);
m_descriptionPanel->setWordWrap(true);
m_descriptionPanel->setFrameStyle(QFrame::Box | QFrame::Sunken);
m_descriptionPanel->setMinimumSize(0, 0);
QSizePolicy p = m_descriptionPanel->sizePolicy();
p.setVerticalPolicy(QSizePolicy::Ignored);
p.setHorizontalPolicy(QSizePolicy::Ignored);
m_descriptionPanel->setSizePolicy(p);
// setup DblClick handler
splitter->handle(1)->installEventFilter(new QtnSplitterEventsHandler(splitter));
m_descriptionSplitter = splitter;
}
m_layout->addWidget(m_descriptionSplitter);
}
else
{
if (m_descriptionSplitter)
{
delete m_descriptionSplitter;
m_descriptionSplitter = nullptr;
m_descriptionPanel = nullptr;
}
m_layout->addWidget(m_propertyView);
}
}