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


C++ TabBar类代码示例

本文整理汇总了C++中TabBar的典型用法代码示例。如果您正苦于以下问题:C++ TabBar类的具体用法?C++ TabBar怎么用?C++ TabBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: layoutButtons

void TabBarPrivate::layoutButtons()
{
    int bw = tabbar->height();
    int w = tabbar->width();
    offset = bw * 4;

    if (tabbar->isLeftToRight()) {
        scrollFirstButton->setGeometry(0, 0, bw, bw);
        scrollFirstButton->setIcon(QIcon(QPixmap(arrow_leftmost_xpm)));
        scrollBackButton->setGeometry(bw, 0, bw, bw);
        scrollBackButton->setIcon(QIcon(QPixmap(arrow_left_xpm)));
        scrollForwardButton->setGeometry(bw*2, 0, bw, bw);
        scrollForwardButton->setIcon(QIcon(QPixmap(arrow_right_xpm)));
        scrollLastButton->setGeometry(bw*3, 0, bw, bw);
        scrollLastButton->setIcon(QIcon(QPixmap(arrow_rightmost_xpm)));
    } else {
        scrollFirstButton->setGeometry(w - bw, 0, bw, bw);
        scrollFirstButton->setIcon(QIcon(QPixmap(arrow_rightmost_xpm)));
        scrollBackButton->setGeometry(w - 2*bw, 0, bw, bw);
        scrollBackButton->setIcon(QIcon(QPixmap(arrow_right_xpm)));
        scrollForwardButton->setGeometry(w - 3*bw, 0, bw, bw);
        scrollForwardButton->setIcon(QIcon(QPixmap(arrow_left_xpm)));
        scrollLastButton->setGeometry(w - 4*bw, 0, bw, bw);
        scrollLastButton->setIcon(QIcon(QPixmap(arrow_leftmost_xpm)));
    }
}
开发者ID:UIKit0,项目名称:calligra,代码行数:26,代码来源:TabBar.cpp

示例2: updateButtons

void TabBarPrivate::updateButtons()
{
    scrollFirstButton->setEnabled(tabbar->canScrollBack());
    scrollBackButton->setEnabled(tabbar->canScrollBack());
    scrollForwardButton->setEnabled(tabbar->canScrollForward());
    scrollLastButton->setEnabled(tabbar->canScrollForward());
}
开发者ID:UIKit0,项目名称:calligra,代码行数:7,代码来源:TabBar.cpp

示例3: createOutputBar

// -- WIN32IDE ---
TabBar* WIN32IDE :: createOutputBar()
{
   TabBar* tabBar = new TabBar(_appWindow, Settings::tabWithAboveScore);

   _output = new Output(tabBar, _appWindow);
   _messageList = new MessageLog(tabBar);

   tabBar->addTabChild(OUTPUT_TAB, _output);
   tabBar->addTabChild(MESSAGES_TAB, _messageList);

   tabBar->_setHeight(120);

   Splitter* bottomSplitter = new Splitter(_appWindow, tabBar, false, IDM_LAYOUT_CHANGED);

   bottomSplitter->_setConstraint(60, 100);

   _appWindow->_getLayoutManager()->setAsBottom(bottomSplitter);

   controls.add(tabBar);
   controls.add(_output);
   controls.add(_messageList);
   controls.add(bottomSplitter);

   return tabBar;
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:26,代码来源:winide.cpp

示例4: openCallList

void MainWindow :: openCallList()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->addTabChild(CALLSTACK_TAB, (Control*)_controls[CTRL_CALLLIST]);
   tabBar->show();
   tabBar->selectTabChild((Control*)_controls[CTRL_CALLLIST]);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:8,代码来源:winide.cpp

示例5: openMessageList

void MainWindow :: openMessageList()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->addTabChild(MESSAGES_TAB, (Control*)_controls[CTRL_MESSAGELIST]);
   tabBar->show();
   tabBar->selectTabChild((Control*)_controls[CTRL_MESSAGELIST]);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:8,代码来源:winide.cpp

示例6: openOutput

void MainWindow :: openOutput()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->addTabChild(OUTPUT_TAB, (Control*)_controls[CTRL_OUTPUT]);
   tabBar->selectTabChild((Control*)_controls[CTRL_OUTPUT]);
   tabBar->show();
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:8,代码来源:winide.cpp

示例7: closeOutput

void MainWindow :: closeOutput()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->removeTabChild((Control*)_controls[CTRL_OUTPUT]);
   if (tabBar->getTabCount() == 0) {
      tabBar->hide();
   }
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:9,代码来源:winide.cpp

示例8: closeCallList

void MainWindow::closeCallList()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->removeTabChild((Control*)_controls[CTRL_CALLLIST]);

   if (tabBar->getTabCount() == 0) {
      tabBar->hide();
   }
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:10,代码来源:winide.cpp

示例9: closeDebugWatch

void MainWindow :: closeDebugWatch()
{
   TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

   tabBar->removeTabChild((Control*)_controls[CTRL_CONTEXTBOWSER]);
   if (tabBar->getTabCount() == 0) {
      tabBar->hide();
   }
   else tabBar->selectLastTabChild();

   hideControl(CTRL_CONTEXTBOWSER);
   refresh();
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:13,代码来源:winide.cpp

示例10: openDebugWatch

void MainWindow :: openDebugWatch()
{
   if (!isControlVisible(CTRL_CONTEXTBOWSER)) {
      TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]);

      tabBar->addTabChild(WATCH_TAB, (Control*)_controls[CTRL_CONTEXTBOWSER]);
      tabBar->selectTabChild((Control*)_controls[CTRL_CONTEXTBOWSER]);
      tabBar->show();

      showControls(CTRL_CONTEXTBOWSER, CTRL_CONTEXTBOWSER);
   }
   refreshControl(CTRL_CONTEXTBOWSER);
   refresh();
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:14,代码来源:winide.cpp

示例11: layoutTabs

void TabBarPrivate::layoutTabs()
{
    tabRects.clear();

    QFont f = font(true);
    QFontMetrics fm(f, tabbar);
    if (tabbar->isLeftToRight()) {
        // left to right
        int x = 0;
        for (int c = 0; c < tabs.count(); c++) {
            QRect rect;
            if (c >= firstTab - 1) {
                QString text = tabs[ c ];
                int tw = fm.width(text) + 4;
                rect = QRect(x, 0, tw + 20, tabbar->height());
                x = x + tw + 20;
            }
            tabRects.append(rect);
        }

        lastTab = tabRects.count();
        for (int i = 0; i < tabRects.count(); i++)
            if (tabRects[i].right() - 10 + offset > tabbar->width()) {
                lastTab = i;
                break;
            }
    } else {
        // right to left
        int x = tabbar->width() - offset;
        for (int c = 0; c < tabs.count(); c++) {
            QRect rect;
            if (c >= firstTab - 1) {
                QString text = tabs[ c ];
                int tw = fm.width(text) + 4;
                rect = QRect(x - tw - 20, 0, tw + 20, tabbar->height());
                x = x - tw - 20;
            }
            tabRects.append(rect);
        }

        lastTab = tabRects.count();
        for (int i = tabRects.count() - 1; i > 0; i--)
            if (tabRects[i].left() > 0) {
                lastTab = i + 1;
                break;
            }
    }
}
开发者ID:UIKit0,项目名称:calligra,代码行数:48,代码来源:TabBar.cpp

示例12: QSize

QSize TabBar::tabSizeHint(int index) const
{
    if (!isVisible()) {
        return QSize(-1, -1);
    }

    const int maxWidth = 250;
    const int minWidth = 100;
    const int minHeight = 27;

    TabBar* tabBar = const_cast<TabBar*>(this);

    QSize size = QTabBar::tabSizeHint(index);
    size.setHeight(qMax(size.height(), minHeight));

    int availableWidth = width() - (m_addTabButton->isVisible() ? m_addTabButton->width() : 0);
    int tabCount = count();
    int boundedWidthForTab = maxWidth;
    int activeTabWidth = boundedWidthForTab;

    if (tabCount > 0) {
        boundedWidthForTab = qBound(minWidth, availableWidth / tabCount, maxWidth);
        if (index == currentIndex()) {
            activeTabWidth = qBound(boundedWidthForTab, availableWidth - (tabCount - 1) * boundedWidthForTab, maxWidth);
            size.setWidth(activeTabWidth);
        }
        else {
            size.setWidth(boundedWidthForTab);
        }
    }

    if (index == tabCount - 1) {
        if (tabCount * boundedWidthForTab > availableWidth) {
            m_addTabButton->hide();
        }
        else {
            int addTabButtonX = (tabCount - 1) * boundedWidthForTab + activeTabWidth;

            if (isRightToLeft()) {
                addTabButtonX = width() - addTabButtonX;
            }

            tabBar->moveAddTabButton(addTabButtonX);
            m_addTabButton->show();
        }
    }
    return size;
}
开发者ID:mkhoeini,项目名称:Saaghar,代码行数:48,代码来源:tabwidget.cpp

示例13: tabSizeHint

QSize TabBar::tabSizeHint(int index) const
{
    QSize size = QTabBar::tabSizeHint(index);
    WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
    TabBar* tabBar = const_cast <TabBar*>(this);
    tabBar->m_adjustingLastTab = false;

    if (webTab && webTab->isPinned()) {
        size.setWidth(PINNED_TAB_WIDTH);
    }
    else {
        int availableWidth = width() - (PINNED_TAB_WIDTH * m_pinnedTabsCount) - m_tabWidget->buttonListTabs()->width() - m_tabWidget->buttonAddTab()->width();
        int normalTabsCount = count() - m_pinnedTabsCount;
        if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) {
            tabBar->m_normalTabWidth = MAXIMUM_TAB_WIDTH;
            size.setWidth(m_normalTabWidth);
        }
        else if (availableWidth < MINIMUM_TAB_WIDTH * normalTabsCount) {
            tabBar->m_normalTabWidth = MINIMUM_TAB_WIDTH;
            size.setWidth(m_normalTabWidth);
        }
        else {
            int maxWidthForTab = availableWidth / normalTabsCount;
            tabBar->m_normalTabWidth = maxWidthForTab;
            //Fill any empty space (we've got from rounding) with last tab
            if (index == count() - 1) {
                tabBar->m_lastTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab;
                tabBar->m_adjustingLastTab = true;
                size.setWidth(m_lastTabWidth);
            }
            else {
                tabBar->m_lastTabWidth = maxWidthForTab;
                size.setWidth(m_lastTabWidth);
            }
        }
    }

    if (index == count() - 1) {
        int xForAddTabButton = (PINNED_TAB_WIDTH * m_pinnedTabsCount) + (count() - m_pinnedTabsCount) * (m_normalTabWidth);
        if (m_adjustingLastTab) {
            xForAddTabButton += m_lastTabWidth - m_normalTabWidth;
        }
        emit tabBar->moveAddTabButton(xForAddTabButton);
    }

    return size;
}
开发者ID:JoseAngelMuyoz,项目名称:QupZilla,代码行数:47,代码来源:tabbar.cpp

示例14: drawTab

void TabBarPrivate::drawTab(QPainter& painter, QRect& rect, const QString& text, bool active)
{
    QPolygon polygon;

    if (tabbar->isLeftToRight())
        polygon << QPoint(rect.x(), rect.y())
        << QPoint(rect.x(), rect.bottom() - 3)
        << QPoint(rect.x() + 2, rect.bottom())
        << QPoint(rect.right() - 4, rect.bottom())
        << QPoint(rect.right() - 2, rect.bottom() - 2)
        << QPoint(rect.right() + 5, rect.top());
    else
        polygon << QPoint(rect.right(), rect.top())
        << QPoint(rect.right(), rect.bottom() - 3)
        << QPoint(rect.right() - 2, rect.bottom())
        << QPoint(rect.x() + 4, rect.bottom())
        << QPoint(rect.x() + 2, rect.bottom() - 2)
        << QPoint(rect.x() - 5, rect.top());

    painter.save();

    // fill it first
    QBrush bg = tabbar->palette().background();
    if (active)
        bg = tabbar->palette().base();
    painter.setBrush(bg);
    painter.setPen(QPen(Qt::NoPen));
    painter.drawPolygon(polygon);

    // draw the lines
    painter.setPen(tabbar->palette().color(QPalette::Dark));
    painter.setRenderHint(QPainter::Antialiasing);
    if (!active) {
        const bool reverseLayout = tabbar->isRightToLeft();
        painter.drawLine(rect.x() - (reverseLayout ? 5 : 0), rect.y(),
                         rect.right() + (reverseLayout ? 0 : 5), rect.top());
    }

    painter.drawPolyline(polygon);

    painter.setPen(tabbar->palette().color(QPalette::ButtonText));
    QFont f = font(active);
    painter.setFont(f);
    QFontMetrics fm = painter.fontMetrics();
    int tx =  rect.x() + (rect.width() - fm.width(text)) / 2;
    int ty =  rect.y() + (rect.height() - fm.height()) / 2 + fm.ascent();
    painter.drawText(tx, ty, text);

    painter.restore();
}
开发者ID:UIKit0,项目名称:calligra,代码行数:50,代码来源:TabBar.cpp

示例15: qDebug

void TabBar::mouseMoveEvent(QMouseEvent* event) {
  // while dragging
  if (event->buttons() & Qt::LeftButton) {
    // If we call winId() here, drag no longer works.
    //  qDebug() << "mouseMoveEvent. pos:" << event->pos() << "globalPos:" << event->globalPos();
    //    qDebug() << "mouseMoveEvent" << event;

    // first mouse enter event after dragging
    if (m_dragInitiated && geometry().contains(event->pos())) {
      qDebug("first mouse enter event");
      finishDrag();

      // Start mouse move
      emit onDetachTabEntered(event->screenPos().toPoint());
      return QTabBar::mouseMoveEvent(event);
    }

    // dragging tab is over an another tab bar.
    TabBar* anotherTabBar = App::tabBarAt(event->screenPos().x(), event->screenPos().y());

    if (m_dragInitiated && anotherTabBar && anotherTabBar != this) {
      qDebug("dragging tab is over an another tab bar.");

      finishDrag();

      // NOTE: dirty Hack!!!
      //
      // TabView A  TabView B
      // tab1 tab2  tab3
      //
      // When starting to move a tab1, in QTabBarPrivate d->pressedIndex is 0
      // When tab1 passes tab2, d->pressedIndex is 1
      // When tab1 moves to TabView B, this code block is executed and onDetachTabEntered is
      // emitted
      // In TabView::detachTabEntered, insertTab is called with tab1
      // TabView B becomes the parent of tab1 and TabView A removes tab1 becaues it's no longer
      // parent
      // In paintEvent of TabView A, it tries to paint d->tabList[d->pressedIndex] but crash occurs
      // because it's out of range
      //
      // In mouseReleaseEvent below, it resets d->pressedIndex to -1 to avoid the situation above

      mouseReleaseEvent(new QMouseEvent(QEvent::MouseButtonRelease, event->screenPos().toPoint(),
                                        Qt::LeftButton, Qt::LeftButton, Qt::NoModifier));

      emit anotherTabBar->onDetachTabEntered(event->screenPos().toPoint());
      anotherTabBar->m_sourceTabBar = this;
      anotherTabBar->grabMouse();
      return;
    }

    if (m_dragInitiated && m_fakeWindow) {
      m_fakeWindow->moveWithOffset(event->globalPos());
      return QTabBar::mouseMoveEvent(event);
    }

    //    qDebug() << "manhattanLength? " << ((event->pos() - m_dragStartPos).manhattanLength() <
    //    QApplication::startDragDistance()) << "outside of tabbar? " <<
    //    !geometry().contains(event->pos());
    if (!m_dragStartPos.isNull() && ((event->buttons() & Qt::LeftButton)) &&
        ((event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) &&
        (!geometry().contains(event->pos()))) {
      m_dragInitiated = true;
      // Stop the move to be able to convert to a drag
      QMouseEvent finishMoveEvent(QEvent::MouseMove, event->pos(), Qt::NoButton, Qt::NoButton,
                                  Qt::NoModifier);
      QTabBar::mouseMoveEvent(&finishMoveEvent);

      // Initiate Drag
      qDebug("start dragging a tab");
      m_fakeWindow = new FakeWindow(this, m_dragStartPos);
      m_fakeWindow->show();
      emit onDetachTabStarted(tabAt(m_dragStartPos), event->screenPos().toPoint());
    } else {
      QTabBar::mouseMoveEvent(event);
    }
    // not dragging
  } else {
    showCloseButtonOnActiveTab(event->pos());
  }
}
开发者ID:silkedit,项目名称:silkedit,代码行数:81,代码来源:TabBar.cpp


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