当前位置: 首页>>代码示例>>C++>>正文


C++ QBoxLayout::direction方法代码示例

本文整理汇总了C++中QBoxLayout::direction方法的典型用法代码示例。如果您正苦于以下问题:C++ QBoxLayout::direction方法的具体用法?C++ QBoxLayout::direction怎么用?C++ QBoxLayout::direction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QBoxLayout的用法示例。


在下文中一共展示了QBoxLayout::direction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addPage

void PropertyToolBox::addPage( QWidget* page )
{
    QBoxLayout* pageLayout = qobject_cast<QBoxLayout*>( page->layout() );
    if ( pageLayout && pageLayout->direction() == QBoxLayout::TopToBottom ) {
        pageLayout->setContentsMargins( 5, 5, 5, 5 );
        pageLayout->setSpacing( 3 );
        for ( int i = 0; i < pageLayout->count(); i++ ) {
            QLayoutItem* item = pageLayout->itemAt( i );
            if ( item->spacerItem() )
                continue;
            QLabel* label = qobject_cast<QLabel*>( item->widget() );
            if ( label ) {
                QString style = "border: none; border-bottom: 1px solid palette(dark);";
                if ( i > 0 )
                    style += "margin-top: 2px;";
                label->setStyleSheet( style );
                continue;
            }
            QBoxLayout* itemLayout = qobject_cast<QBoxLayout*>( item->layout() );
            if ( itemLayout && itemLayout->direction() == QBoxLayout::LeftToRight ) {
                itemLayout->insertSpacing( 0, 10 );
            } else {
                pageLayout->removeItem( item );
                QHBoxLayout* wrapperLayout = new QHBoxLayout();
                wrapperLayout->addSpacing( 10 );
                wrapperLayout->addItem( item );
                pageLayout->insertLayout( i, wrapperLayout );
            }
        }
    }

    page->setBackgroundRole( QPalette::Base );

    addItem( page, page->windowTitle() );
}
开发者ID:WhiteSymmetry,项目名称:fraqtive,代码行数:35,代码来源:propertytoolbox.cpp

示例2: direction

QBoxLayout::Direction QBoxLayoutProto::direction() const
{
  QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject());
  if (item)
    return item->direction();
  return QBoxLayout::LeftToRight;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: layoutChanged

void GraphicsView::
        setLayoutDirection( QBoxLayout::Direction direction )
{
    QBoxLayout* bl = dynamic_cast<QBoxLayout*>(layout_widget_->layout());
    if (bl->direction() != direction)
    {
        bl->setDirection( direction );

        emit layoutChanged( direction );
    }
}
开发者ID:aveminus,项目名称:freq,代码行数:11,代码来源:graphicsview.cpp

示例4: QWidget

CWindowIcon::CWindowIcon(WId window, QWidget* parent)
  : QWidget(parent),
    m_window(window)
{
  QBoxLayout* box = qobject_cast<QBoxLayout*>(parent->layout());
  Q_ASSERT(box);

  m_size = box->direction() <= QBoxLayout::RightToLeft ? parentWidget()->height() : parentWidget()->width();

  X11Core::registerForTrayIconUpdates(window);
  X11Core::reparentWindow(window, parentWidget()->winId());
  X11Core::resizeWindow(window, m_size, m_size);
  X11Core::redirectWindow(window);
  X11Core::mapWindow(window);
  X11Core::registerForTrayIconUpdates(window);

  connect(X11Core::instance(), SIGNAL(windowDamaged(WId)),
          this               , SLOT(onWindowDamaged(WId)));

  connect(X11Core::instance(), SIGNAL(windowReconfigured(WId,int,int,int,int)),
          this               , SLOT(onWindowReconfigured(WId,int,int,int,int)));
}
开发者ID:GravisZro,项目名称:qtpanel,代码行数:22,代码来源:trayplugin.cpp

示例5: paintEvent

//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tMediaButtonBox::paintEvent( QPaintEvent* /*pEvent*/ )
{
    QPainter painter( this );
    const QRect rect = contentsRect();

    // background
    painter.fillRect( rect, palette().window() );

    // separator drawing is supported only for QBoxLayout
    QBoxLayout* pLayout = qobject_cast< QBoxLayout* >( layout() );
    if( !pLayout )
        return;

    // if there is no space between the items, we don't draw any separator
    int halfSpacing = qRound( pLayout->spacing() * 0.5 );
    if( halfSpacing == 0 )
        return;

    // setup the pen to draw separators
    tNOSStyle* pNosStyle = qobject_cast< tNOSStyle* >( style() );
    if( pNosStyle )
    {
        QColor c = pNosStyle->GetColor( tNOSStyle::eNCR_Alternative1 );
        c.setAlpha( 127 );
        QPen pen( c );
        pen.setCosmetic( true );
        painter.setPen( pen );
    }

    // separator bounds (X for horizontal sep, Y for vertical sep)
    int separatorOffset;
    if( pLayout->direction() == QBoxLayout::LeftToRight || pLayout->direction() == QBoxLayout::RightToLeft )
    {
        separatorOffset = rect.height() / 7;
    }
    else
    {
        separatorOffset = rect.width() / 8;
    }
    int separatorX1 = rect.left() + separatorOffset;
    int separatorX2 = rect.right() - separatorOffset;
    int separatorY1 = rect.top() + separatorOffset;
    int separatorY2 = rect.bottom() - separatorOffset;

    // find the first visible widget or spacer (layouts are not handled yet, see below)
    int from = 0;
    QLayoutItem* fromItem = 0;
    for( from = 0; from < pLayout->count(); ++from )
    {
        fromItem = pLayout->itemAt( from );
        if( ( fromItem->widget() && fromItem->widget()->isVisible() ) || fromItem->spacerItem() )
            break;
    }

    // iterate over each item and draw a separator between:
    // - two visible widgets
    // - a spacer and a visible widget
    // - a visible widget and a spacer
    // to be noted that embedded layouts are not handled yet (must be wrapped in a widget)
    for( int to = from + 1; to < pLayout->count(); ++to )
    {
        QLayoutItem* toItem = pLayout->itemAt( to );

        if( toItem->widget() )
        {
            // if toItem is a visible widget, process it; if it is hidden, skip it
            if( toItem->widget()->isHidden() )
                continue;
        }
        else if( toItem->spacerItem() )
        {
            // skip empty spacer
            if( toItem->geometry().isEmpty() )
                continue;

            if( fromItem->spacerItem() )
            {
                // if fromItem and toItem are spacers, just take toItem as
                // the new reference but don't draw any separator
                from = to;
                fromItem = toItem;
                continue;
            }
        }

        // because a spacer item "eat" the spacing (i.e. there is no spacing added after a spacer)
        // we need to adjust the separator offset
        int tunedHalfSpacing = halfSpacing;
        if( fromItem->spacerItem() )
            tunedHalfSpacing -= pLayout->spacing();

        switch( pLayout->direction() )
        {
        case QBoxLayout::LeftToRight:
            {
                int x = fromItem->geometry().right() + tunedHalfSpacing;
                painter.drawLine( x, separatorY1, x, separatorY2 );
//.........这里部分代码省略.........
开发者ID:dulton,项目名称:53_hero,代码行数:101,代码来源:tMediaButtonBox.cpp

示例6: layoutDirection

QBoxLayout::Direction GraphicsView::
        layoutDirection()
{
    QBoxLayout* bl = dynamic_cast<QBoxLayout*>(layout_widget_->layout());
    return bl->direction();
}
开发者ID:aveminus,项目名称:freq,代码行数:6,代码来源:graphicsview.cpp

示例7: getOrientation

bool TDockWidget::getOrientation() const {
  QBoxLayout *boxLayout = static_cast<QBoxLayout *>(layout());

  return (boxLayout->direction() == QBoxLayout::TopToBottom) ? vertical
                                                             : horizontal;
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:6,代码来源:tdockwindows.cpp


注:本文中的QBoxLayout::direction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。