本文整理汇总了C++中QRect::bottomLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ QRect::bottomLeft方法的具体用法?C++ QRect::bottomLeft怎么用?C++ QRect::bottomLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRect
的用法示例。
在下文中一共展示了QRect::bottomLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
//-----------------------------------------------------------------------------
// Function: RibbonGroup::paintEvent()
//-----------------------------------------------------------------------------
void RibbonGroup::paintEvent(QPaintEvent* /*event*/)
{
QPainter painter(this);
// Draw the base gradient.
QLinearGradient gradient(rect().topLeft(), rect().bottomLeft());
gradient.setColorAt(0.0, RibbonTheme::GRADIENTTOP);
gradient.setColorAt(0.1, Qt::white);
gradient.setColorAt(0.3, RibbonTheme::GRADIENTTOP);
gradient.setColorAt(1.0, RibbonTheme::GRADIENTBOTTOM);
painter.setRenderHints(QPainter::Antialiasing);
painter.fillRect(rect(), gradient);
// Draw a nice frame around the group area.
painter.setPen(QPen(RibbonTheme::GROUPTITLEGRADIENTTOP, 1));
painter.drawRect(rect());
// Draw the title background.
QRect titleRect = rect();
titleRect.setTop(rect().height() - TITLE_HEIGHT);
QLinearGradient titleGradient(titleRect.topLeft(), titleRect.bottomLeft());
titleGradient.setColorAt(0.0, RibbonTheme::GROUPTITLEGRADIENTTOP);
titleGradient.setColorAt(1.0, RibbonTheme::GROUPTITLEGRADIENTBOTTOM);
painter.fillRect(titleRect, titleGradient);
// Draw the title text.
QTextOption opt;
opt.setAlignment(Qt::AlignCenter);
painter.setPen(QPen(RibbonTheme::GROUPTITLETEXT));
painter.drawText(titleRect, title_, opt);
}
示例2: paint
void SelectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if(!m_selection->pasteImage().isNull()) {
if(m_shape.size() == 4) {
QPolygonF src({
QPointF(0, 0),
QPointF(m_selection->pasteImage().width(), 0),
QPointF(m_selection->pasteImage().width(), m_selection->pasteImage().height()),
QPointF(0, m_selection->pasteImage().height())
});
QTransform t;
if(QTransform::quadToQuad(src, m_shape, t)) {
painter->save();
painter->setTransform(t, true);
painter->drawImage(0, 0, m_selection->pasteImage());
painter->restore();
} else
qWarning("Couldn't transform pasted image!");
} else {
qWarning("Pasted selection item with non-rectangular polygon!");
}
}
painter->setClipRect(boundingRect().adjusted(-1, -1, 1, 1));
QPen pen;
pen.setWidth(qApp->devicePixelRatio());
pen.setColor(Qt::white);
pen.setStyle(Qt::DashLine);
pen.setDashOffset(m_marchingants);
pen.setCosmetic(true);
painter->setPen(pen);
painter->setCompositionMode(QPainter::RasterOp_SourceXorDestination);
if(m_selection->isClosed())
painter->drawPolygon(m_shape);
else
painter->drawPolyline(m_shape);
// Draw resizing handles
if(m_selection->isClosed()) {
QRect rect = m_selection->boundingRect();
pen.setWidth(m_selection->handleSize());
pen.setStyle(Qt::SolidLine);
painter->setPen(pen);
painter->drawPoint(rect.topLeft());
painter->drawPoint(rect.topLeft() + QPointF(rect.width()/2, 0));
painter->drawPoint(rect.topRight());
painter->drawPoint(rect.topLeft() + QPointF(0, rect.height()/2));
painter->drawPoint(rect.topRight() + QPointF(0, rect.height()/2));
painter->drawPoint(rect.bottomLeft());
painter->drawPoint(rect.bottomLeft() + QPointF(rect.width()/2, 0));
painter->drawPoint(rect.bottomRight());
}
}
示例3: roundedRect
QRegion BusyDialog::roundedRect(const QRect &rect, int round)
{
QRegion region;
// middle and borders
region += rect.adjusted(round, 0, -round, 0);
region += rect.adjusted(0, round, 0, -round);
// top left
QRect corner(rect.topLeft(), QSize(round*2, round*2));
region += QRegion(corner, QRegion::Ellipse);
// top right
corner.moveTopRight(rect.topRight());
region += QRegion(corner, QRegion::Ellipse);
// bottom left
corner.moveBottomLeft(rect.bottomLeft());
region += QRegion(corner, QRegion::Ellipse);
// bottom right
corner.moveBottomRight(rect.bottomRight());
region += QRegion(corner, QRegion::Ellipse);
return region;
}
示例4: QCursor
QCursor core::common::getCursor(const QPoint &pos, const QRect &rect, int clearance, const QCursor &defCursor, bool ignoreCorners)
{
double
distTopLeft = math::distance(pos, rect.topLeft()),
distTopRight = math::distance(pos, rect.topRight()),
distBottomRight = math::distance(pos, rect.bottomRight()),
distBottomLeft = math::distance(pos, rect.bottomLeft()),
distTop = std::abs(pos.y() - rect.top()),
distRight = std::abs(pos.x() - rect.right()),
distBottom = std::abs(pos.y() - rect.bottom()),
distLeft = std::abs(pos.x() - rect.left()),
clearanceRadius = clearance/2;
if((distTop <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distTopRight <= clearanceRadius)) || (distBottom <= clearanceRadius && !(distBottomLeft <= clearanceRadius) && !(distBottomRight <= clearanceRadius))){
return QCursor(Qt::SizeVerCursor);
}else if((distRight <= clearanceRadius && !(distTopRight <= clearanceRadius) && !(distBottomRight <= clearanceRadius)) || (distLeft <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distBottomLeft <= clearanceRadius))){
return QCursor(Qt::SizeHorCursor);
}else if((distTopLeft <= clearanceRadius || distBottomRight <= clearanceRadius) && !ignoreCorners){
return QCursor(Qt::SizeFDiagCursor);
}else if((distTopRight <= clearanceRadius || distBottomLeft <= clearanceRadius) && !ignoreCorners){
return QCursor(Qt::SizeBDiagCursor);
}
return defCursor;
}
示例5: drawGrid
void IsometricRenderer::drawGrid(QPainter *painter, const QRectF &rect,
QColor gridColor) const
{
const int tileWidth = map()->tileWidth();
const int tileHeight = map()->tileHeight();
QRect r = rect.toAlignedRect();
r.adjust(-tileWidth / 2, -tileHeight / 2,
tileWidth / 2, tileHeight / 2);
const int startX = qMax(qreal(0), pixelToTileCoords(r.topLeft()).x());
const int startY = qMax(qreal(0), pixelToTileCoords(r.topRight()).y());
const int endX = qMin(qreal(map()->width()),
pixelToTileCoords(r.bottomRight()).x());
const int endY = qMin(qreal(map()->height()),
pixelToTileCoords(r.bottomLeft()).y());
gridColor.setAlpha(128);
QPen gridPen(gridColor);
gridPen.setDashPattern(QVector<qreal>() << 2 << 2);
painter->setPen(gridPen);
for (int y = startY; y <= endY; ++y) {
const QPointF start = tileToPixelCoords(startX, y);
const QPointF end = tileToPixelCoords(endX, y);
painter->drawLine(start, end);
}
for (int x = startX; x <= endX; ++x) {
const QPointF start = tileToPixelCoords(x, startY);
const QPointF end = tileToPixelCoords(x, endY);
painter->drawLine(start, end);
}
}
示例6: pressMove
void KstGfxPictureMouseHandler::pressMove(KstTopLevelViewPtr view, const QPoint& pos, bool shift, const QRect& geom) {
if (_cancelled || !_mouseDown) {
return;
}
QRect old = _prevBand;
_prevBand = KstGfxMouseHandlerUtils::newRect(pos, _mouseOrigin, geom, shift);
if (old != _prevBand) {
QPainter p;
p.begin(view->widget());
p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
p.setRasterOp(Qt::NotROP);
if (old.topLeft() != QPoint(-1, -1)) {
p.drawRect(old);
p.drawLine(old.topLeft(), old.bottomRight());
p.drawLine(old.topRight(), old.bottomLeft());
}
p.drawRect(_prevBand);
p.drawLine(_prevBand.topRight(), _prevBand.bottomLeft());
p.drawLine(_prevBand.topLeft(), _prevBand.bottomRight());
p.end();
}
}
示例7: getClueRectDown
QRect KkrBoardView::getClueRectDown(const QRect &cellRect) const
{
const QPoint bottomLeft{cellRect.bottomLeft()};
const int x = bottomLeft.x() + 2;
const int y = bottomLeft.y() - CLUE_WIDTH - 1;
return QRect(x, y, CLUE_WIDTH, CLUE_WIDTH);
}
示例8: if
core::common::Sides core::common::nearToSide(const QPoint &pos, const QRect &rect, int clearance, bool ignoreCorners)
{
double
distTopLeft = math::distance(pos, rect.topLeft()),
distTopRight = math::distance(pos, rect.topRight()),
distBottomRight = math::distance(pos, rect.bottomRight()),
distBottomLeft = math::distance(pos, rect.bottomLeft()),
distTop = std::abs(pos.y() - rect.top()),
distRight = std::abs(pos.x() - rect.right()),
distBottom = std::abs(pos.y() - rect.bottom()),
distLeft = std::abs(pos.x() - rect.left()),
clearanceRadius = clearance/2;
if(distTop <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distTopRight <= clearanceRadius)){
return Top;
}else if(distBottom <= clearanceRadius && !(distBottomLeft <= clearanceRadius) && !(distBottomRight <= clearanceRadius)){
return Bottom;
}else if(distRight <= clearanceRadius && !(distTopRight <= clearanceRadius) && !(distBottomRight <= clearanceRadius)){
return Right;
}else if(distLeft <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distBottomLeft <= clearanceRadius)){
return Left;
}else if(distTopLeft <= clearanceRadius && !ignoreCorners){
return TopLeft;
}else if(distBottomRight <= clearanceRadius && !ignoreCorners){
return BottomRight;
}else if(distTopRight <= clearanceRadius && !ignoreCorners){
return TopRight;
}else if(distBottomLeft <= clearanceRadius && !ignoreCorners){
return BottomLeft;
}else{
return None;
}
}
示例9: QFontMetricsF
RectKey::RectKey(KeyCode keycode, const QRect &textGeometry, const QRect &keyGeometry,
const QSize &labelSize,
int topLeft, int topRight, int bottomLeft, int bottomRight,
const QColor &keyColor, const QColor &textColor, const QColor &secondColor, const QColor &alphaColor,
const QString &labelText, const QString &secondText, const QString &alphaText,
const QFont &labelFont, const QFont &secondFont, const QFont &alphaFont,
Qt::Alignment labelAlign, Qt::Alignment secondAlign, Qt::Alignment alphaAlign)
: Key{keycode, textGeometry, keyGeometry, keyColor},
mTextColor{textColor}, mSecondColor{secondColor}, mAlphaColor{alphaColor},
mLabelAlign{labelAlign}, mSecondAlign{secondAlign}, mAlphaAlign{alphaAlign},
mLabelFont{labelFont}, mSecondFont{secondFont.resolve(labelFont)},
mAlphaFont{alphaFont.resolve(labelFont)},
mSecondText{secondText}, mAlphaText{alphaText} {
QRect corner;
mLabelText = labelText;
mKeyShape.moveTo(keyGeometry.topLeft() + QPointF{0, topLeft * .5});
corner.setSize({bottomLeft, bottomLeft});
corner.moveBottomLeft(keyGeometry.bottomLeft());
mKeyShape.arcTo(corner, 90 * 2, 90);
corner.setSize({bottomRight, bottomRight});
corner.moveBottomRight(keyGeometry.bottomRight());
mKeyShape.arcTo(corner, 90 * 3, 90);
corner.setSize({topRight, topRight});
corner.moveTopRight(keyGeometry.topRight());
mKeyShape.arcTo(corner, 90 * 0, 90);
corner.setSize({topLeft, topLeft});
corner.moveTopLeft(keyGeometry.topLeft());
mKeyShape.arcTo(corner, 90 * 1, 90);
mLabelFont.setPixelSize(labelSize.height());
mLabelFont.setStretch(labelSize.width() * mLabelFont.stretch() /
QFontMetricsF(mLabelFont).size(Qt::TextSingleLine, mLabelText).width());
}
示例10: roundedRect
// Thanks to http://www.qtcentre.org/threads/3205-Toplevel-widget-with-rounded-corners?p=17492#post17492
QRegion QzTools::roundedRect(const QRect &rect, int radius)
{
QRegion region;
// middle and borders
region += rect.adjusted(radius, 0, -radius, 0);
region += rect.adjusted(0, radius, 0, -radius);
// top left
QRect corner(rect.topLeft(), QSize(radius * 2, radius * 2));
region += QRegion(corner, QRegion::Ellipse);
// top right
corner.moveTopRight(rect.topRight());
region += QRegion(corner, QRegion::Ellipse);
// bottom left
corner.moveBottomLeft(rect.bottomLeft());
region += QRegion(corner, QRegion::Ellipse);
// bottom right
corner.moveBottomRight(rect.bottomRight());
region += QRegion(corner, QRegion::Ellipse);
return region;
}
示例11: slotUpdateResizeHandles
void MechanicsItemOverlay::slotUpdateResizeHandles()
{
const PositionInfo absPos = p_mechanicsItem->absolutePosition();
const QRect sizeRect = p_mechanicsItem->sizeRect();
QPointArray pa(9);
pa[0] = sizeRect.topLeft();
pa[2] = sizeRect.topRight();
pa[1] = (pa[0]+pa[2])/2;
pa[4] = sizeRect.bottomRight();
pa[3] = (pa[2]+pa[4])/2;
pa[6] = sizeRect.bottomLeft();
pa[5] = (pa[4]+pa[6])/2;
pa[7] = (pa[6]+pa[0])/2;
pa[8] = QPoint(0,0);
QWMatrix m;
m.rotate(absPos.angle() * DPR);
pa = m.map(pa);
m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() );
m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() );
m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() );
m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() );
m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() );
m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() );
m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() );
m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() );
m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() );
}
示例12: paintEvent
void CellButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QStyleOptionToolButton opt;
initStyleOption(&opt);
QPainter p(this);
QIcon::Mode mode = opt.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
if (mode == QIcon::Normal && (opt.state & QStyle::State_HasFocus || opt.state & QStyle::State_Sunken))
mode = QIcon::Active;
QIcon::State state = QIcon::Off;
if (opt.state & QStyle::State_On)
state = QIcon::On;
if (m_pos == Center || m_pos == Right)
{
p.setPen(QColor("#F8F8F8"));
QRect rcBorder = rect();
p.drawLine(rcBorder.topLeft(), rcBorder.bottomLeft());
}
//m_backgroundIcon.paint(&p, opt.rect, Qt::AlignCenter, QIcon::Normal, state);
QSize size = iconSize();
QRect rcIcon((opt.rect.width() - size.width()) / 2, (opt.rect.height() - size.height()) / 2, size.width(), size.height());
if (opt.icon.isNull()) {
m_iconNomal.paint(&p, rcIcon, Qt::AlignCenter, mode, state);
} else {
opt.icon.paint(&p, rcIcon, Qt::AlignCenter, mode, state);
}
}
示例13: createWidgets
void NonPdfCropping::createWidgets(QGraphicsScene &scene)
{
const double MARGIN_PERCENT = 5.0;
const int ZERO_WIDTH_IS_ALWAYS_VISIBLE = 0;
int marginHor = scene.width() * MARGIN_PERCENT / 100.0;
int marginVer = scene.height() * MARGIN_PERCENT / 100.0;
QRect box (scene.sceneRect().left() + marginHor,
scene.sceneRect().top() + marginVer,
scene.sceneRect().width() - 2 * marginHor,
scene.sceneRect().height() - 2 * marginVer);
m_handleTL = new NonPdfFrameHandle (scene, m_view, box.topLeft() , NON_PDF_CROPPING_LEFT | NON_PDF_CROPPING_TOP , *this, Z_HANDLE);
m_handleTR = new NonPdfFrameHandle (scene, m_view, box.topRight() , NON_PDF_CROPPING_RIGHT | NON_PDF_CROPPING_TOP , *this, Z_HANDLE);
m_handleBR = new NonPdfFrameHandle (scene, m_view, box.bottomRight(), NON_PDF_CROPPING_RIGHT | NON_PDF_CROPPING_BOTTOM , *this, Z_HANDLE);
m_handleBL = new NonPdfFrameHandle (scene, m_view, box.bottomLeft() , NON_PDF_CROPPING_LEFT | NON_PDF_CROPPING_BOTTOM , *this, Z_HANDLE);
m_box = new QGraphicsRectItem;
m_box->setZValue (Z_BOX);
m_box->setPen (QPen (QBrush (Qt::gray), ZERO_WIDTH_IS_ALWAYS_VISIBLE));
scene.addItem (m_box);
updateBox ();
}
示例14: DrawBar
void FreeSpaceBar::DrawBar(QPainter* p, const QRect& r) {
p->setRenderHint(QPainter::Antialiasing, true);
p->setRenderHint(QPainter::HighQualityAntialiasing, true);
QRect bar_rect(r);
bar_rect.setWidth(float(bar_rect.width()) * (float(total_ - free_) / total_));
QLinearGradient background_gradient(r.topLeft(), r.bottomLeft());
background_gradient.setColorAt(0, kColorBg1);
background_gradient.setColorAt(1, kColorBg2);
QLinearGradient bar_gradient(bar_rect.topLeft(), bar_rect.bottomLeft());
bar_gradient.setColorAt(0, kColorBar1);
bar_gradient.setColorAt(1, kColorBar2);
// Draw the background
p->setPen(Qt::NoPen);
p->setBrush(background_gradient);
p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius);
// Create a path to use for clipping the bars
QPainterPath clip_path;
clip_path.addRoundedRect(r, kBarBorderRadius, kBarBorderRadius);
p->setClipPath(clip_path);
// Draw any additional space
if (additional_) {
QRect additional_rect(bar_rect);
additional_rect.setLeft(bar_rect.right());
additional_rect.setWidth(
float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1);
QLinearGradient additional_gradient(additional_rect.topLeft(),
additional_rect.bottomLeft());
additional_gradient.setColorAt(0, kColorAdd1);
additional_gradient.setColorAt(1, kColorAdd2);
p->fillRect(additional_rect, additional_gradient);
}
// Draw the bar foreground
p->fillRect(bar_rect, bar_gradient);
// Draw a border
p->setClipping(false);
p->setPen(kColorBorder);
p->setBrush(Qt::NoBrush);
p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius);
// Draw marker lines over the top every few pixels
p->setOpacity(0.35);
p->setRenderHint(QPainter::Antialiasing, false);
p->setPen(QPen(palette().color(QPalette::Light), 1.0));
for (int x = r.left() + kMarkerSpacing; x < r.right(); x += kMarkerSpacing) {
p->drawLine(x, r.top() + 2, x, r.bottom() - 2);
}
p->setOpacity(1.0);
}
示例15: paintTab
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
QStyleOptionTabV2 tab;
initStyleOption(&tab, tabIndex);
QRect rect = tab.rect;
painter->save();
bool selected = tab.state & QStyle::State_Selected;
bool hover = tab.state & QStyle::State_MouseOver;
#ifdef Q_WS_MAC
hover = false; // Dont hover on Mac
#endif
QColor hoverColor;
if (hover)
{
hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame() * 2);
}
QColor light = QColor(255, 255, 255, 40);
QColor dark = QColor(0, 0, 0, 60);
if (selected)
{
painter->fillRect(tab.rect, QColor(0x47, 0x47, 0x47));
painter->setPen(QPen(light, 0));
painter->drawLine(rect.topLeft(), rect.topRight());
painter->setPen(QPen(dark, 0));
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
}
else
{
painter->fillRect(tab.rect, StyleHelper::baseColor());
if (hover)
painter->fillRect(tab.rect, hoverColor);
}
QString tabText(tab.text);
QRect tabTextRect(tab.rect);
QRect tabIconRect(tab.rect);
QFont font(painter->font());
font.setPointSizeF(StyleHelper::sidebarFontSize());
font.setBold(false);
painter->setFont(font);
painter->setPen(Qt::white);
int textFlags = Qt::AlignCenter | Qt::AlignCenter | Qt::ElideRight | Qt::TextWordWrap;
painter->drawText(tabTextRect, textFlags, tabText);
painter->setPen(selected ? QColor(60, 60, 60) : Qt::white);
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
tabIconRect.adjust(0, 4, 0, -textHeight);
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
tab.icon.pixmap(QSize(64, 64)));
// painter->translate(0, -1);
// painter->drawText(tabTextRect, textFlags, tabText);
painter->restore();
}