本文整理汇总了C++中QPolygon::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::push_back方法的具体用法?C++ QPolygon::push_back怎么用?C++ QPolygon::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMarkerArea
QPolygon QStyleRangeSlider::getMarkerArea(const QRect& bbox,
const QPair<int, int>& range,
const QPair<int, int>& cutoffRange,
QStyleRangeSlider::WHICH which) const
{
QPolygon paintArea;
int width = markerWidth;
int pos;
if (which & FIRST) {
pos = getPosMin(bbox, range.first, cutoffRange);
width = -width;
}
else {
assert(which & SECOND);
pos = getPosMin(bbox, range.second, cutoffRange);
}
int y = getGrooveY(bbox);
int base = y + getGrooveHeight(bbox);
y -= tipOffset/2;
int tip = base + tipOffset;
paintArea.push_back(QPoint(pos, y));
paintArea.push_back(QPoint(pos, tip));
paintArea.push_back(QPoint(pos + width, base));
paintArea.push_back(QPoint(pos + width, y));
paintArea.push_back(paintArea[0]);
return paintArea;
}
示例2:
QPolygon
CQXYValsCanvas::
toQPolygon(const CXYVals::Polygon &polygon) const
{
QPolygon poly;
for (int i = 0; i < polygon.size(); ++i)
poly.push_back(QPoint(polygon.x[i], polygon.y[i]));
poly.push_back(QPoint(polygon.x[0], polygon.y[0]));
return poly;
}
示例3: rect
void PanWidget::
recreatePolygon ()
{
QPoint o = rect().center();
QPoint x = (rect().topRight() - rect().topLeft())/4;
QPoint y = (rect().bottomLeft() - rect().topLeft())/4;
QPolygon poly;
float R = 1.5;
float r = 0.25;
poly.push_back( o - R*y );
poly.push_back( o + r*x - r*y);
poly.push_back( o + R*x );
poly.push_back( o + r*x + r*y);
poly.push_back( o + R*y );
poly.push_back( o - r*x + r*y);
poly.push_back( o - R*x );
poly.push_back( o - r*x - r*y);
path_ = QPainterPath();
path_.addPolygon(poly);
setMask(HudGlWidget::growRegion(poly));
update();
}
示例4: getPolygon
QPolygon Shape::getPolygon(int w, int h)
{
QPolygon polygon;
if (ui->radioButtonPolygone->isChecked())
polygon = dialogPolygon.mPolygon;
else
{
if (ui->radioButtonRectangle->isChecked())
{
polygon.push_back(QPoint(0,0));
polygon.push_back(QPoint(0,20));
polygon.push_back(QPoint(30, 20));
polygon.push_back(QPoint(30,0));
}
else
{
int nbPoints = 36;
double slice = 2 * (atan(1.0)*4) /nbPoints;
double rad, px, py;
int rayon;
if(h > w)
rayon = w / 2;
else
rayon = h / 2;
for (int i = 0; i < nbPoints; i++)
{
rad = slice * i;
px = 200 + rayon * cos(rad);
py = 120 + rayon * sin(rad);
polygon.push_back(QPoint(px,py));
}
}
}
return polygon;
}
示例5: mapItemToWidget
QPolygon ControlRuler::mapItemToWidget(QPolygonF *poly)
{
// double xscale = width() / m_pannedRect.width();
// double yscale = height();
QPolygon newpoly;
QPoint newpoint;
for (QPolygonF::iterator it = poly->begin(); it != poly->end(); ++it) {
newpoint.setX(mapXToWidget((*it).x()));
newpoint.setY(mapYToWidget((*it).y()));
newpoly.push_back(newpoint);
}
return newpoly;
}
示例6: 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();
}
}
示例7: recreatePolygon
QPolygon RescaleWidget::
recreatePolygon ()
{
QPoint o = rect().center();
QPoint x = scalex_ * (rect().topRight() - rect().topLeft())/4;
QPoint y = scaley_ * (rect().bottomLeft() - rect().topLeft())/4;
QPolygon poly;
float d = 0.3;
float r = 0.1;
poly.push_back( o - r*x - r*y);
poly.push_back( o - d*x - y);
poly.push_back( o + d*x - y);
poly.push_back( o + r*x - r*y);
poly.push_back( o - d*y + x);
poly.push_back( o + d*y + x);
poly.push_back( o + r*x + r*y);
poly.push_back( o + d*x + y);
poly.push_back( o - d*x + y);
poly.push_back( o - r*x + r*y);
poly.push_back( o + d*y - x);
poly.push_back( o - d*y - x);
if ( 0 == "push a circle" )
{
float N = max(width(), height());
for (float i=0; i<N; ++i)
{
float a = 2*M_PI*(i/N);
poly.push_back(o + x*cos(a) + y*sin(a));
}
}
path_ = QPainterPath();
path_.addPolygon(poly);
update();
return poly;
}
示例8: sideBarPaintEvent
void TraceWidget::sideBarPaintEvent(QPaintEvent * event)
{
// don't paint anything if there are no cycles
if (cycle_.first < 0 || cycle_.second < 0)
return;
QPainter painter(cbar_);
QRect rct, first_rct, last_rct;
int first_id = -1, last_id = -1;
for (int i = 0; i < count(); ++i) {
rct = visualItemRect(item(i));
if (rct.top() > event->rect().bottom())
break;
if (rct.bottom() <= event->rect().top())
continue;
if (i >= cycle_.second && i <= cycle_.first) {
if (first_id == -1) {
first_id = i;
first_rct = rct;
}
last_id = i;
last_rct = rct;
}
}
// draw nothing
if (first_id == -1)
return;
QList<QPolygon> lines;
QPolygon line;
// start of the cycle
if (last_id == cycle_.first) {
const int base_off = last_rct.top() + (last_rct.height() - cycleBaseSize) / 2;
const int line_off = last_rct.top() + last_rct.height() / 2;
line.push_back(QPoint(cycleBarWidth - 2, base_off));
line.push_back(QPoint(cycleBarWidth - 2, base_off + cycleBaseSize));
lines.append(line);
line.clear();
line.push_back(QPoint(cycleBarWidth - 2, line_off));
line.push_back(QPoint(cycleLeftOffset, line_off));
} else {
line.push_back(QPoint(cycleLeftOffset, last_rct.bottom()));
}
const int line_off = first_rct.top() + first_rct.height() / 2;
// end
if (first_id == cycle_.second) {
line.push_back(QPoint(cycleLeftOffset, line_off));
line.push_back(QPoint(cycleBarWidth - 2, line_off));
lines.append(line);
// arrow
line.clear();
line.push_back(QPoint(cycleBarWidth - 4, line_off - 2));
line.push_back(QPoint(cycleBarWidth - 2, line_off));
line.push_back(QPoint(cycleBarWidth - 4, line_off + 2));
lines.append(line);
} else {
line.push_back(QPoint(cycleLeftOffset, first_rct.top()));
lines.append(line);
}
QPen pen;
painter.setPen(pen);
foreach(QPolygon itr, lines) {
painter.drawPolyline(itr);
}