本文整理汇总了C++中QPolygon::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::reserve方法的具体用法?C++ QPolygon::reserve怎么用?C++ QPolygon::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toPolygon
QPolygon QPolygonF::toPolygon() const
{
QPolygon a;
a.reserve(size());
for (int i=0; i<size(); ++i)
a.append(at(i).toPoint());
return a;
}
示例2: paintEvent
void MainTabBar::paintEvent(QPaintEvent *) {
QPainter p(this);
QLinearGradient g(QPointF(0,0), QPointF(BASE_WIDTH,0));
g.setSpread(QLinearGradient::PadSpread);
g.setColorAt(0.0, QColor(170,170,170));
g.setColorAt(1.0 - 1.0 / BASE_WIDTH, QColor(235,235,235));
g.setColorAt(1.0, QColor(49,49,49));
p.fillRect(QRect(QPoint(0,0),this->size()), g);
QFont font;
unsigned accumulator(TOP_MARGIN);
for (int i(0); i != this->count(); ++i) {
QSize size(tabSizeHint(i));
if (this->currentIndex() == i) {
QLinearGradient g(QPointF(0,0), QPointF(BASE_WIDTH,0));
g.setSpread(QLinearGradient::PadSpread);
g.setColorAt(0.0, QColor(64,64,64));
g.setColorAt(1.0 - 1.0 / BASE_WIDTH, QColor(130,130,130));
g.setColorAt(1.0, QColor(49,49,49));
QPolygon polygon;
polygon.reserve(6);
if (i) {
polygon.push_back(QPoint(0,accumulator - ARROW_HEIGHT / 2));
polygon.push_back(QPoint(size.width() / 2,accumulator + ARROW_HEIGHT / 2));
polygon.push_back(QPoint(size.width(),accumulator - ARROW_HEIGHT / 2));
} else {
polygon.push_back(QPoint(0,accumulator));
polygon.push_back(QPoint(size.width(),accumulator));
}
polygon.push_back(QPoint(size.width(),accumulator + size.height() - ARROW_HEIGHT / 2));
polygon.push_back(QPoint(size.width() / 2,accumulator + size.height() + ARROW_HEIGHT / 2));
polygon.push_back(QPoint(0,accumulator + size.height() - ARROW_HEIGHT / 2));
QPainterPath path;
path.addPolygon(polygon);
p.fillPath(path, g);
}
this->tabIcon(i).paint(&p,QRect(BASE_WIDTH / 2 - iconSize / 2, accumulator + ARROW_HEIGHT / 2,iconSize,iconSize));
QTextOption options(Qt::AlignCenter);
options.setWrapMode(QTextOption::WordWrap);
p.drawText(QRect(0, iconSize + ARROW_HEIGHT / 2 + accumulator, BASE_WIDTH, ROW_HEIGHT),this->tabText(i),options);
accumulator += size.height();
}
}