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


C++ QSplitter::orientation方法代码示例

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


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

示例1: split

void SplitView::split(BufferView* view, Qt::Orientation orientation)
{
    if (view) {
        QSplitter* container = qobject_cast<QSplitter*>(view->parentWidget());
        if (container) {
            int index = container->indexOf(view);
            BufferView* bv = 0;
            const int size = (orientation == Qt::Horizontal ? container->width() : container->height()) - container->handleWidth();
            if (container->count() == 1 || container->orientation() == orientation) {
                container->setOrientation(orientation);
                bv = createBufferView(container, index + 1);
                QList<int> sizes;
                for (int i = 0; i < container->count(); ++i)
                    sizes += size / container->count();
                container->setSizes(sizes);
            } else if (index != -1) {
                QList<int> sizes = container->sizes();
                QSplitter* splitter = wrap(view, orientation);
                if (splitter) {
                    container->setSizes(sizes);
                    bv = createBufferView(splitter);
                    splitter->setSizes(QList<int>() << size/2 << size/2);
                }
            }
            if (bv) {
                bv->setBuffer(view->buffer());
                emit viewAdded(bv);
            }
        }
    }
}
开发者ID:communi,项目名称:communi-desktop,代码行数:31,代码来源:splitview.cpp

示例2: splitViewSpace

void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0
    Qt::Orientation o )// = Qt::Horizontal
{
  // emergency: fallback to activeViewSpace, and if still invalid, abort
  if (!vs) vs = activeViewSpace();
  if (!vs) return;

  // get current splitter, and abort if null
  QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
  if (!currentSplitter) return;

  // index where to insert new splitter/viewspace
  const int index = currentSplitter->indexOf( vs );

  // create new viewspace
  KateViewSpace* vsNew = new KateViewSpace( this );

  // only 1 children -> we are the root container. So simply set the orientation
  // and add the new view space, then correct the sizes to 50%:50%
  if (currentSplitter->count() == 1)
  {
    if( currentSplitter->orientation() != o )
      currentSplitter->setOrientation( o );
    QList<int> sizes = currentSplitter->sizes();
    sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2;
    sizes[0] = sizes[1];
    currentSplitter->insertWidget( index, vsNew );
    currentSplitter->setSizes( sizes );
  }
  else
  {
    // create a new QSplitter and replace vs with the splitter. vs and newVS are
    // the new children of the new QSplitter
    QSplitter* newContainer = new QSplitter( o );
    newContainer->setOpaqueResize( KGlobalSettings::opaqueResize() );
    QList<int> currentSizes = currentSplitter->sizes();

    newContainer->addWidget( vs );
    newContainer->addWidget( vsNew );
    currentSplitter->insertWidget( index, newContainer );
    newContainer->show();

    // fix sizes of children of old and new splitter
    currentSplitter->setSizes( currentSizes );
    QList<int> newSizes = newContainer->sizes();
    newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
    newSizes[1] = newSizes[0];
    newContainer->setSizes( newSizes );
  }

  m_viewSpaceList.append( vsNew );
  activeViewSpace()->setActive( false );
  vsNew->setActive( true, true );
  vsNew->show();

  createView ((KTextEditor::Document*)activeView()->document());

  updateViewSpaceActions ();
}
开发者ID:rtaycher,项目名称:kate,代码行数:59,代码来源:kateviewmanager.cpp

示例3: dropViewInsidePane

void ViewAreaImpl::dropViewInsidePane(ViewPane* pane, View* view, int dropEdge)
{
    if(dropEdge == OVER){
        addView(pane, view, true);

    } else {
        QSize destSize = pane->size();

        QSplitter* parentSplitter = static_cast<QSplitter*>(pane->parentWidget());

        if(parentSplitter->count() >= 2){
            QList<int> sizes = parentSplitter->sizes();
            QSplitter* newSplitter = new QSplitter(parentSplitter);
            parentSplitter->insertWidget(parentSplitter->indexOf(pane), newSplitter);
            newSplitter->addWidget(pane);
            parentSplitter->setSizes(sizes);
            parentSplitter = newSplitter;
        }
        
        ViewPane* newViewPane = new ViewPane(this, parentSplitter);

        if(dropEdge == LEFT){
            parentSplitter->setOrientation(Qt::Horizontal);
            parentSplitter->insertWidget(0, newViewPane);
        } else if(dropEdge == RIGHT){
            parentSplitter->setOrientation(Qt::Horizontal);
            parentSplitter->insertWidget(1, newViewPane);
        } else if(dropEdge == TOP){
            parentSplitter->setOrientation(Qt::Vertical);
            parentSplitter->insertWidget(0, newViewPane);
        } else {
            parentSplitter->setOrientation(Qt::Vertical);
            parentSplitter->insertWidget(1, newViewPane);
        }
        addView(newViewPane, view, true);

        int half;
        if(parentSplitter->orientation() == Qt::Horizontal){
            half = destSize.height() / 2;
        } else {
            half = destSize.width() / 2;
        }
        QList<int> sizes;
        sizes << half << half;
        parentSplitter->setSizes(sizes);
    }
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:47,代码来源:ViewArea.cpp


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