本文整理汇总了C++中QLayout::setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::setContentsMargins方法的具体用法?C++ QLayout::setContentsMargins怎么用?C++ QLayout::setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::setContentsMargins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void WWidgetGroup::setup(QDomNode node) {
setContentsMargins(0, 0, 0, 0);
// Set background pixmap if available
if (!WWidget::selectNode(node, "BackPath").isNull()) {
setPixmapBackground(WWidget::getPath(WWidget::selectNodeQString(node, "BackPath")));
}
QLayout* pLayout = NULL;
if (!XmlParse::selectNode(node, "Layout").isNull()) {
QString layout = XmlParse::selectNodeQString(node, "Layout");
if (layout == "vertical") {
pLayout = new QVBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
} else if (layout == "horizontal") {
pLayout = new QHBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
}
}
if (pLayout) {
setLayout(pLayout);
}
}
示例2: UBFloatingPalette
UBZoomPalette::UBZoomPalette(QWidget* parent)
: UBFloatingPalette(Qt::BottomRightCorner, parent)
, mIsExpanded(1)
{
mBoardController = UBApplication::boardController;
QLayout* layout = new QVBoxLayout(this);
mCurrentZoomButton = new QPushButton(parent);
mCurrentZoomButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }"));
mCurrentZoomButton->setFocusPolicy(Qt::NoFocus);
connect(mCurrentZoomButton, SIGNAL(clicked(bool)), this, SLOT(showHideExtraButton()));
connect(mBoardController, SIGNAL(zoomChanged(qreal)), this, SLOT(refreshPalette()));
connect(mBoardController, SIGNAL(activeSceneChanged()), this, SLOT(refreshPalette()));
mHundredButton = new QPushButton(parent);
mHundredButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }"));
mHundredButton->setFocusPolicy(Qt::NoFocus);
mHundredButton->setIcon(QIcon(":/images/stylusPalette/restoreZoom.png"));
mHundredButton->setIconSize(QSize(42,42));
connect(mHundredButton, SIGNAL(clicked(bool)), this, SLOT(goHundred()));
layout->setContentsMargins(radius() + 15, 4, radius() + 15, 4);
layout->addWidget(mHundredButton);
layout->addWidget(mCurrentZoomButton);
hide();
refreshPalette();
}
示例3: connect
void
ViewManager::insertViewStep( int before, ViewStep* step)
{
m_steps.insert( before, step );
QLayout* layout = step->widget()->layout();
if ( layout )
{
layout->setContentsMargins( 0, 0, 0, 0 );
}
m_stack->insertWidget( before, step->widget() );
connect( step, &ViewStep::nextStatusChanged,
this, [this]( bool status )
{
ViewStep* vs = qobject_cast< ViewStep* >( sender() );
if ( vs )
{
if ( vs == m_steps.at( m_currentStep ) )
m_next->setEnabled( status );
}
} );
m_stack->setCurrentIndex( 0 );
step->widget()->setFocus();
}
示例4: QWidget
QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper* editorWidget, QgsAttributeForm* form )
: QWidget( form )
, mWidget( editorWidget )
, mForm( form )
, mMode( DefaultMode )
, mMultiEditButton( new QgsMultiEditToolButton() )
, mBlockValueUpdate( false )
, mIsMixed( false )
, mIsChanged( false )
{
if ( !mWidget || !mForm )
return;
QLayout* l = new QHBoxLayout();
l->setMargin( 0 );
l->setContentsMargins( 0, 0, 0, 0 );
l->addWidget( mWidget->widget() );
if ( mWidget->widget() )
{
mWidget->widget()->setObjectName( mWidget->field().name() );
}
connect( mWidget, SIGNAL( valueChanged( const QVariant& ) ), this, SLOT( editorWidgetChanged( const QVariant & ) ) );
connect( mMultiEditButton, SIGNAL( resetFieldValueTriggered() ), this, SLOT( resetValue() ) );
connect( mMultiEditButton, SIGNAL( setFieldValueTriggered() ), this, SLOT( setFieldTriggered() ) );
mMultiEditButton->setField( mWidget->field() );
setLayout( l );
updateWidgets();
}
示例5: propertyMap
/*!
\internal
*/
QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
{
// Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
// Set its margins to 0.
bool layoutWidget = d->processingLayoutWidget();
QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
if (layoutWidget) {
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
int left, top, right, bottom;
left = top = right = bottom = 0;
const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
if (DomProperty *prop = properties.value(strings.leftMarginProperty))
left = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.topMarginProperty))
top = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.rightMarginProperty))
right = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.bottomMarginProperty))
bottom = prop->elementNumber();
l->setContentsMargins(left, top, right, bottom);
d->setProcessingLayoutWidget(false);
}
return l;
}
示例6: FlowLayout
ItemSelectorWidget::ItemSelectorWidget( QWidget* parent )
:StylableWidget(parent), m_clearText( false )
{
QLayout* layout = new FlowLayout( this, 0, 0, 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 0 );
}
示例7: QDialog
StickyNoteEditDialog::StickyNoteEditDialog()
: QDialog(NULL, Qt::FramelessWindowHint|Qt::SubWindow)
, _edit(NULL)
, _noteInset(10)
{
// make this window a child of the BumpTop window to hide it in the task bar
// HWND hwnd = WindowFromDC(getDC());
// SetParent(hwnd, winOS->GetWindowsHandle());
// resize and center the window
resize(320, 320);
move(winOS->GetWindowWidth() / 2 - width() / 2,
winOS->GetWindowHeight() / 2 - height() / 2);
setStyleSheet(QT_NT("QDialog {")
QT_NT("border: 0px;")
QT_NT("}"));
setAttribute(Qt::WA_TranslucentBackground);
// create the dialog content
QLayout * layout = NULL;
layout = new QHBoxLayout(this);
layout->setContentsMargins(20, 20, 25, 30);
_edit = new StickyNoteTextEdit();
_edit->setStyleSheet(QT_NT("QTextEdit {")
QT_NT("background: rgb(0,0,0,0);")
QT_NT("border: 0px;")
QT_NT("selection-color: rgb(240,240,240);")
QT_NT("selection-background-color: rgb(60,60,60);")
QT_NT("}"));
layout->addWidget(_edit);
connect(_edit, SIGNAL(accept()), this, SLOT(onEditAccept()));
// try and forward focus events to the edit field
setFocusProxy(_edit);
}
示例8: QWidget
RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
, mRootNode(0)
{
osgViewer::CompositeViewer& viewer = CompositeViewer::get();
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
//ds->setNumMultiSamples(8);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->windowName = "";
traits->windowDecoration = true;
traits->x = 0;
traits->y = 0;
traits->width = width();
traits->height = height();
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();
// Doesn't make much sense as we're running on demand updates, and there seems to be a bug with the refresh rate when running multiple QGLWidgets
traits->vsync = false;
mView = new osgViewer::View;
osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get());
QLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(window->getGLWidget());
setLayout(layout);
// Pass events through this widget first
window->getGLWidget()->installEventFilter(this);
mView->getCamera()->setGraphicsContext(window);
mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
lightMgr->setStartLight(1);
lightMgr->setLightingMask(Mask_Lighting);
mRootNode = lightMgr;
mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
mView->setSceneData(mRootNode);
// Press S to reveal profiling stats
mView->addEventHandler(new osgViewer::StatsHandler);
mView->getCamera()->setCullMask(~(Mask_UpdateVisitor));
viewer.addView(mView);
viewer.setDone(false);
viewer.realize();
}
示例9: resetWidgetLayout
void BackgroundWidget::resetWidgetLayout(MainWidget &widget)
{
// If the widget has layout, remove its margins because main widgets layout has its own margins.
QLayout *layout = widget.layout();
if (layout != nullptr) {
layout->setContentsMargins(0, 0, 0, 0);
}
}
示例10: setup
void WWidgetGroup::setup(QDomNode node, const SkinContext& context) {
setContentsMargins(0, 0, 0, 0);
// Set background pixmap if available
if (context.hasNode(node, "BackPath")) {
setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")));
}
QLayout* pLayout = NULL;
if (context.hasNode(node, "Layout")) {
QString layout = context.selectString(node, "Layout");
if (layout == "vertical") {
pLayout = new QVBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
} else if (layout == "horizontal") {
pLayout = new QHBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
}
}
if (pLayout && context.hasNode(node, "SizeConstraint")) {
QMap<QString, QLayout::SizeConstraint> constraints;
constraints["SetDefaultConstraint"] = QLayout::SetDefaultConstraint;
constraints["SetFixedSize"] = QLayout::SetFixedSize;
constraints["SetMinimumSize"] = QLayout::SetMinimumSize;
constraints["SetMaximumSize"] = QLayout::SetMaximumSize;
constraints["SetMinAndMaxSize"] = QLayout::SetMinAndMaxSize;
constraints["SetNoConstraint"] = QLayout::SetNoConstraint;
QString sizeConstraintStr = context.selectString(node, "SizeConstraint");
if (constraints.contains(sizeConstraintStr)) {
pLayout->setSizeConstraint(constraints[sizeConstraintStr]);
} else {
qDebug() << "Could not parse SizeConstraint:" << sizeConstraintStr;
}
}
if (pLayout) {
setLayout(pLayout);
}
}
示例11: layout
void
CQGroupBox::
calculateFrame()
{
QLayout *l = layout();
if (! l) return;
l->setContentsMargins(marginLeft(), spaceTop(), marginRight(), spaceBottom());
}
示例12: WWidget
WLabel::WLabel(QWidget * parent) : WWidget(parent)
{
m_pLabel = new QLabel(this);
QLayout* pLayout = new QVBoxLayout(this);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->addWidget(m_pLabel);
setLayout(pLayout);
m_qsText = "";
}
示例13: setWidgetPaddingAndSpacing
// 设置 widget 的 padding 和 spacing
void UiUtil::setWidgetPaddingAndSpacing(QWidget *widget, int padding, int spacing) {
// 设置 Widget 的 padding 和 spacing
QLayout *layout = widget->layout();
if (nullptr != layout) {
layout->setContentsMargins(padding, padding, padding, padding);
layout->setSpacing(spacing);
}
}
示例14: WWidget
WNumber::WNumber(QWidget * parent) : WWidget(parent)
{
m_pLabel = new QLabel(this);
QLayout* pLayout = new QVBoxLayout(this);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->addWidget(m_pLabel);
setLayout(pLayout);
m_qsText = "";
m_dConstFactor = 0.;
}
示例15: eventFilter
bool Drawer::eventFilter(QObject *obj, QEvent *event)
{
const QEvent::Type type = event->type();
if (QEvent::Move == type || QEvent::Resize == type) {
QLayout *t = layout();
if (t && 16 != t->contentsMargins().right()) {
t->setContentsMargins(0, 0, 16, 0);
}
}
return OverlayWidget::eventFilter(obj, event);
}