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


C++ TabBar::isLeftToRight方法代码示例

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


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

示例3: 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


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