本文整理汇总了C++中QPolygon::translated方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::translated方法的具体用法?C++ QPolygon::translated怎么用?C++ QPolygon::translated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::translated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grabRect
void FreeRegionGrabber::grabRect()
{
QPolygon pol = selection;
if ( !pol.isEmpty() )
{
grabbing = true;
int xOffset = pixmap.rect().x() - pol.boundingRect().x();
int yOffset = pixmap.rect().y() - pol.boundingRect().y();
QPolygon translatedPol = pol.translated(xOffset, yOffset);
QPixmap pixmap2(pol.boundingRect().size());
pixmap2.fill(Qt::transparent);
QPainter pt;
pt.begin(&pixmap2);
if (pt.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
pt.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
pt.setBrush(Qt::black);
pt.setPen(QPen(QBrush(Qt::black), 0.5));
pt.drawPolygon(translatedPol);
pt.setCompositionMode(QPainter::CompositionMode_SourceIn);
} else {
pt.setClipRegion(QRegion(translatedPol));
pt.setCompositionMode(QPainter::CompositionMode_Source);
}
pt.drawPixmap(pixmap2.rect(), pixmap, pol.boundingRect());
pt.end();
emit freeRegionUpdated(pol);
emit freeRegionGrabbed(pixmap2);
}
}
示例2: paintEvent
void paintEvent( QPaintEvent* pe ) override
{
Q_UNUSED( pe );
QPainter p;
p.begin( this );
p.setPen( Qt::red );
QPolygonF t = mPoly.translated( -mPoly.boundingRect().left(), -mPoly.boundingRect().top() );
p.drawConvexPolygon( t );
p.end();
}