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


C++ TabWidget::removeSplit方法代码示例

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


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

示例1: closePane

void TabWidget::closePane() {
    /*If it is floating we do not need to re-arrange the splitters containing the tab*/
    if (isFloating()) {
        parentWidget()->close();
        return;
    }
    
    Splitter* container = dynamic_cast<Splitter*>(parentWidget());
    if(!container) {
        return;
    }
    
    
    /*Removing it from the _panes vector*/
    _gui->removePane(this);
    
    /*Only sub-panes are closable. That means the splitter owning them must also
     have a splitter as parent*/
    Splitter* parentContainer = dynamic_cast<Splitter*>(container->parentWidget());
    if(!parentContainer) {
        return;
    }
    
    QList<int> mainContainerSizes = parentContainer->sizes();

    
    /*identifying the other tab*/
    QWidget* other = 0;
    getOtherTabWidget(container,this,other);
    assert(other);
    
    bool vertical;
    bool removeOk = false;
    
    {
        Splitter*  parentSplitter = container;
        ///The only reason becasue this is not ok is because we split this TabWidget again
        while (!removeOk && parentSplitter) {
            
            for (int i = 0; i < parentSplitter->count(); ++i) {
                TabWidget* tab = dynamic_cast<TabWidget*>(parentSplitter->widget(i));
                if (tab && tab != this) {
                    removeOk = tab->removeSplit(this,&vertical);
                    if (removeOk) {
                        break;
                    }
                }
            }
            
            parentSplitter = dynamic_cast<Splitter*>(parentSplitter->parentWidget());
        }
    }
    
    ///iterate recursively over parents splitter to find a tabwidget where to move the tabs
    TabWidget* firstParentTabWidget = NULL;
    getTabWidgetRecursively(parentContainer,firstParentTabWidget);
    assert(firstParentTabWidget);
    Splitter* firstParentSplitter = dynamic_cast<Splitter*>(firstParentTabWidget->parentWidget());
    assert(firstParentSplitter);

    ///move this tab's splits to the first parent tab widget
    for (std::map<TabWidget*,bool>::iterator it = _userSplits.begin();it != _userSplits.end();++it) {
        firstParentTabWidget->_userSplits.insert(*it);
        removeTagNameRecursively(it->first,!vertical);
    }
    
    
    
    /*Removing "what" from the container and delete it*/
    setVisible(false);
    //move all its tabs to the  firstParentTabWidget
    
    while(count() > 0) {
        moveTab(tabAt(0), firstParentTabWidget);
    }
    
    // delete what;
    
    /*Removing the container from the mainContainer*/
    int subSplitterIndex = 0;
    for (int i = 0; i < parentContainer->count(); ++i) {
        Splitter* subSplitter = dynamic_cast<Splitter*>(parentContainer->widget(i));
        if (subSplitter && subSplitter == container) {
            subSplitterIndex = i;
            container->setVisible(false);
            container->setParent(0);
            break;
        }
    }
    /*moving the other to the mainContainer*/
    parentContainer->insertWidget(subSplitterIndex, other);
    other->setVisible(true);
    other->setParent(parentContainer);
    
    ///restore the main container sizes
    parentContainer->setSizes_mt_safe(mainContainerSizes);
    
    /*deleting the subSplitter*/
    _gui->removeSplitter(container);
    delete container;
//.........这里部分代码省略.........
开发者ID:ndeebook,项目名称:Natron,代码行数:101,代码来源:TabWidget.cpp

示例2: closePane

void TabWidget::closePane(){
    /*If it is floating we do not need to re-arrange the splitters containing the tab*/
    if (isFloating()) {
        parentWidget()->close();
        destroyTabs();
        return;
    }
    
    Splitter* container = dynamic_cast<Splitter*>(parentWidget());
    if(!container) {
        return;
    }
    
    /*Removing it from the _panes vector*/
    _gui->removePane(this);
    
    /*Only sub-panes are closable. That means the splitter owning them must also
     have a splitter as parent*/
    Splitter* mainContainer = dynamic_cast<Splitter*>(container->parentWidget());
    if(!mainContainer) {
        return;
    }
    
    /*identifying the other tab*/
    TabWidget* other = 0;
    for (int i = 0; i < container->count(); ++i) {
        TabWidget* tab = dynamic_cast<TabWidget*>(container->widget(i));
        if (tab && tab != this) {
            other = tab;
            break;
        }
    }
    assert(other);
    other->removeSplit(this);
    
    /*Removing "what" from the container and delete it*/
    setVisible(false);
    //move all its tabs to the other TabWidget
    while(count() > 0) {
        moveTab(tabAt(0), other);
    }
    // delete what;
    
    /*Removing the container from the mainContainer*/
    int subSplitterIndex = 0;
    for (int i = 0; i < mainContainer->count(); ++i) {
        Splitter* subSplitter = dynamic_cast<Splitter*>(mainContainer->widget(i));
        if (subSplitter && subSplitter == container) {
            subSplitterIndex = i;
            container->setVisible(false);
            container->setParent(0);
            break;
        }
    }
    /*moving the other to the mainContainer*/
    if(other){
        other->setVisible(true);
        other->setParent(mainContainer);
    }
    mainContainer->insertWidget(subSplitterIndex, other);
    
    /*deleting the subSplitter*/
    _gui->removeSplitter(container);
    delete container;
}
开发者ID:bonalex01,项目名称:Natron,代码行数:65,代码来源:TabWidget.cpp


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