本文整理汇总了C++中TabBar::width方法的典型用法代码示例。如果您正苦于以下问题:C++ TabBar::width方法的具体用法?C++ TabBar::width怎么用?C++ TabBar::width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabBar
的用法示例。
在下文中一共展示了TabBar::width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
示例2: 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)));
}
}