本文整理汇总了C++中QRect::bottomRight方法的典型用法代码示例。如果您正苦于以下问题:C++ QRect::bottomRight方法的具体用法?C++ QRect::bottomRight怎么用?C++ QRect::bottomRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRect
的用法示例。
在下文中一共展示了QRect::bottomRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTab
void QColorTabWidget::drawTab( QPainter& p, QRect& rectTab, const TabInfo& ti, bool bHover, bool bActive, bool bNotify )
{
QPainterPath tabPath;
QPainterPath tabS;
int nDiameter = 3 << 1;
QRectF arcRect( 0, 0, nDiameter, nDiameter );
if (isHorzTab())
{
// Horz-Tab
tabPath.moveTo( rectTab.bottomLeft() );
tabPath.lineTo( rectTab.left(), rectTab.top()+nDiameter/2);
tabS.moveTo( rectTab.left(), rectTab.top()+nDiameter/2 );
arcRect.moveTo( rectTab.topLeft() );
tabPath.arcTo( arcRect, 180, -90 );
tabS.arcTo( arcRect, 180, -90 );
tabPath.lineTo( rectTab.right()-nDiameter/2, rectTab.top() );
tabS.lineTo( rectTab.right()-nDiameter/2, rectTab.top() );
arcRect.moveTo( rectTab.right()-nDiameter, rectTab.top() );
tabPath.arcTo( arcRect, 90, -90 );
tabS.arcTo( arcRect, 90, -90 );
tabPath.lineTo( rectTab.bottomRight() );
tabS.closeSubpath();
//tabPath.closeSubpath();
}
else
{
// Vert-Tab
tabPath.moveTo( rectTab.right(), rectTab.y() );
tabPath.lineTo( rectTab.x()+nDiameter, rectTab.y() );
tabS.moveTo( rectTab.x()+nDiameter, rectTab.y() );
arcRect.moveTo(rectTab.topLeft());
tabPath.arcTo( arcRect, -270, 90 );
tabS.arcTo( arcRect, -270, 90 );
arcRect.moveTo(rectTab.x(), rectTab.bottom()-nDiameter);
tabPath.arcTo( arcRect, -180, 90 );
tabS.arcTo( arcRect, -180, 90 );
tabPath.moveTo( rectTab.left()+nDiameter, rectTab.bottom() );
tabPath.lineTo( rectTab.right(), rectTab.bottom() );
tabS.closeSubpath();
//tabPath.closeSubpath();
}
QColor colorBody;
if (bNotify && (m_nBlinkCount % 2 == 0))
{
colorBody = QColor(252, 209, 211);
}
else
{
if (bActive)
colorBody = QColor(255, 255, 255);
else
colorBody = QColor(0xF5, 0xF5, 0xF5);
}
p.fillPath( tabPath, QBrush(colorBody) );
QColor colorStart = bActive ? ti.clrTab : (bHover ? QColor(255, 190, 60, 200) : QColor(255, 255, 255, 200));
QColor colorEnd(255, 255, 255, 200);
QRectF rectTabTip;
rectTabTip = tabS.boundingRect();
QLinearGradient gradTip;
if (!isHorzTab())
{
gradTip.setStart(rectTabTip.left(), rectTabTip.center().y());
gradTip.setFinalStop(rectTabTip.right(), rectTabTip.center().y());
}
else
{
gradTip.setStart(rectTabTip.center().x(), rectTabTip.top());
gradTip.setFinalStop(rectTabTip.center().x(), rectTabTip.bottom());
}
gradTip.setColorAt( 0, colorStart );
gradTip.setColorAt( 1.f, colorEnd );
p.setBrush(Qt::NoBrush);
p.setPen( QPen(QColor(160,160,160,100), 2.f) );
p.drawPath( tabPath );
p.setPen( QPen(QColor(160,160,160)) );
p.drawPath( tabPath );
p.fillPath( tabS, QBrush(gradTip) );
if (bActive || bHover)
{
p.setPen( colorStart );
p.drawPath( tabS );
}
QRectF rectText;
float fTextOffset = ti.pIconImage ? ti.pIconImage->width()+5.f : 0.f;
if (isHorzTab())
{
rectText.setX((float)rectTab.x() + fTextOffset);
rectText.setY((float)rectTab.y() + nDiameter/2);
rectText.setWidth((float)rectTab.width() - fTextOffset);
//.........这里部分代码省略.........
示例2: mouseMoveEvent
void CScreenShotView::mouseMoveEvent(QMouseEvent *event)
{
if(m_isLocked)
{
event->accept();
return;
}
if((event->buttons() & Qt::LeftButton) && m_isPressed)
{
m_selectRectItem->setVisible(true);
m_endPoint = event->pos();
QPointF startPoint = getPointToSelectedItem(m_startPoint);
QPointF endPoint = getPointToSelectedItem(event->pos());
QPointF maxPoint = getPointToSelectedItem(QPointF(this->geometry().width(),this->geometry().height()));
if(m_shotStatus == CSCREEN_SHOT_STATE_INITIALIZED)
{
if(endPoint.x() > maxPoint.x())
{
endPoint.setX(maxPoint.x());
}
if(endPoint.y() > maxPoint.y())
{
endPoint.setY(maxPoint.y());
}
if(endPoint.x() < 0)
{
endPoint.setX(0);
}
if(endPoint.y() < 0)
{
endPoint.setY(0);
}
// QRectF rect = getPositiveRect(startPoint,endPoint);
QRectF rect = CScreenshotUtil::convertLineFToRectF(QLineF(startPoint,endPoint));
m_selectRectItem->setSelectedRect(rect);
updateTooltipItem();
}
else if(m_shotStatus == CSCREEN_SHOT_STATE_SELECTED)
{
updateSelectRect(startPoint,endPoint);
}
else if(m_shotStatus == CSCREEN_SHOT_STATE_EDITED && m_currentRectItem)
{
// QRectF rect = getPositiveRect(m_startPoint,event->pos());
// QRectF rect = CScreenshotUtil::convertLineFToRectF(QLineF(m_startPoint,event->pos()));
// m_currentRectItem->setPainterRect(rect);
m_currentRectItem->setPainterLine(QLine(m_startPoint,event->pos()));
m_currentRectItem->setVisible(true);
}
}
if(m_shotStatus == CSCREEN_SHOT_STATE_INITIALIZED)
{
updatePreviewItem(event->pos());
if(!m_isPressed && !m_windowRectList.isEmpty())
{
QRect rect = getMouseOnWindowRect(event->globalPos());
QPoint startPoint = m_desktopScreen->geometry().topLeft();
QPointF topLeft = getPointToSelectedItem(rect.topLeft() - startPoint);
QPointF bottomRight = getPointToSelectedItem(rect.bottomRight() - startPoint);
QRectF selectRect(topLeft,bottomRight);
if(selectRect.isValid())
{
m_selectRectItem->setVisible(true);
m_selectRectItem->setSelectedRect(selectRect);
}
}
}
updateCursor(getPointToSelectedItem(event->pos()));
return QGraphicsView::mouseMoveEvent(event);
}
示例3: paintEvent
void Storage::paintEvent(QPaintEvent *anEvent)
{
QLabel::paintEvent(anEvent);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
//painter.setRenderHint(QPainter::SmoothPixmapTransform);
QPen pen;
if (NoTool != tool_) {
pen.setWidth(5);
pen.setColor(QColor(Qt::white));
pen.setStyle(Qt::DashLine);
painter.setPen(pen);
if (BoundingBoxTool == tool_) {
/* с учётом масштаба */
QRect bbox = rect.getCoordinates();
QPoint bboxTopLeft = bbox.topLeft() * scale_;
QPoint bboxBottomRight = bbox.bottomRight() * scale_;
bbox.setTopLeft(bboxTopLeft);
bbox.setBottomRight(bboxBottomRight);
painter.drawRect(bbox);
}
else if (EllipseTool == tool_) {
/* с учётом масштаба */
QRect elli = ell.getCoordinates().normalized();
QPoint ellTopLeft = elli.topLeft() * scale_;
QPoint ellBottomRight = elli.bottomRight() * scale_;
elli.setTopLeft(ellTopLeft);
elli.setBottomRight(ellBottomRight);
if(1 < elli.height() && 1 < elli.width() )
{
painter.drawEllipse(elli);
}
// painter.drawRect(ell);
}
else if (ArrowTool == tool_) {
/* с учётом масштаба */
QLineF line = arrow.getCoordinates();
QPointF p1 = line.p1() * scale_;
QPointF p2 = line.p2() * scale_;
line.setP1(p1);
line.setP2(p2);
if(1 < line.length())
{
double angle = ::acos(line.dx() / line.length());
qreal Pi = atan(1)*4;
if (line.dy() >= 0)
angle = (Pi * 2) - angle;
QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrow_size_,
cos(angle + Pi / 3) * arrow_size_);
QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrow_size_,
cos(angle + Pi - Pi / 3) * arrow_size_);
QPolygonF arrowTop;
arrowTop.clear();
arrowTop << line.p1() << arrowP1 << arrowP2;
painter.drawLine(line);
painter.drawPolygon(arrowTop);///111
qDebug() << "arrowTop" << arrowTop;
arrow_top_ = arrowTop;
}
}
else if (PolygonTool == tool_) {
/* с учётом масштаба */
QPoint point;
QPolygon pol = poly.getCoordinates();
for (int i = 0; i < pol.size(); i++) {
point.setX(pol.at(i).x());
point.setY(pol.at(i).y());
point *= scale_;
pol.remove(i);
pol.insert(i, point);
}
painter.drawPolygon(pol);
}
}
/* рисуем фигуры */
drawBoundingBoxes(&painter, &pen);
drawPolygons(&painter, &pen);
drawEllipses(&painter, &pen);
drawArrows(&painter, &pen);
}
示例4: viewportToScene
// convert viewport coordinate to the original image (not scaled).
QRect ImageView::viewportToScene(const QRect& rect) {
// QPolygon poly = mapToScene(imageItem_->rect());
QPoint topLeft = mapToScene(rect.topLeft()).toPoint();
QPoint bottomRight = mapToScene(rect.bottomRight()).toPoint();
return QRect(topLeft, bottomRight);
}
示例5: drawPrimitive
void WindowsModernStyle::drawPrimitive( PrimitiveElement element, const QStyleOption* option,
QPainter* painter, const QWidget* widget ) const
{
switch ( element ) {
case PE_Widget:
if ( qobject_cast<const QMainWindow*>( widget ) ) {
QRect rect = option->rect;
if ( QStatusBar* statusBar = widget->findChild<QStatusBar*>() ) {
rect.adjust( 0, 0, 0, -statusBar->height() );
painter->setPen( option->palette.light().color() );
painter->drawLine( rect.bottomLeft() + QPoint( 0, 1 ),
rect.bottomRight() + QPoint( 0, 1 ) );
}
QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
gradient.setColorAt( 0.0, m_colorBackgroundBegin );
gradient.setColorAt( 0.6, m_colorBackgroundEnd );
painter->fillRect( rect, gradient );
return;
}
if ( qobject_cast<const QToolBox*>( widget ) ) {
QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
gradient.setColorAt( 0.4, m_colorBackgroundBegin );
gradient.setColorAt( 1.0, m_colorBackgroundEnd );
painter->fillRect( option->rect, gradient );
return;
}
if ( isToolBoxPanel( widget ) ) {
QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
gradient.setColorAt( 0.4, m_colorBarMiddle );
gradient.setColorAt( 1.0, m_colorBarBegin );
painter->fillRect( option->rect, gradient );
return;
}
break;
case PE_WindowGradient: {
QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
gradient.setColorAt( 0.0, m_colorBackgroundBegin );
gradient.setColorAt( 0.6, m_colorBackgroundEnd );
painter->fillRect( option->rect, gradient );
return;
}
case PE_PanelMenuBar:
return;
case PE_FrameMenu:
painter->setPen( m_colorMenuBorder );
painter->setBrush( Qt::NoBrush );
painter->drawRect( option->rect.adjusted( 0, 0, -1, -1 ) );
if ( const QMenu* menu = qobject_cast<const QMenu*>( widget ) ) {
if ( const QMenuBar* menuBar = qobject_cast<const QMenuBar*>( menu->parent() ) ) {
QRect rect = menuBar->actionGeometry( menu->menuAction() );
if ( !rect.isEmpty() ) {
painter->setPen( m_colorMenuBackground );
painter->drawLine( 1, 0, rect.width() - 2, 0 );
}
}
}
if ( const QToolBar* toolBar = qobject_cast<const QToolBar*>( widget ) ) {
QRect rect = option->rect.adjusted( 1, 1, -1, -1 );
QLinearGradient gradient;
if ( toolBar->orientation() == Qt::Vertical )
gradient = QLinearGradient( rect.topLeft(), rect.topRight() );
else
gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() );
gradient.setColorAt( 0.0, m_colorBarBegin );
gradient.setColorAt( 0.4, m_colorBarMiddle );
gradient.setColorAt( 0.6, m_colorBarMiddle );
gradient.setColorAt( 1.0, m_colorBarEnd );
painter->fillRect( rect, gradient );
}
return;
case PE_IndicatorToolBarHandle:
if ( option->state & State_Horizontal ) {
for ( int i = option->rect.height() / 5; i <= 4 * ( option->rect.height() / 5 ); i += 5 ) {
int x = option->rect.left() + 3;
int y = option->rect.top() + i + 1;
painter->fillRect( x + 1, y, 2, 2, m_colorHandleLight );
painter->fillRect( x, y - 1, 2, 2, m_colorHandle );
}
} else {
for ( int i = option->rect.width() / 5; i <= 4 * ( option->rect.width() / 5 ); i += 5 ) {
int x = option->rect.left() + i + 1;
int y = option->rect.top() + 3;
painter->fillRect( x, y + 1, 2, 2, m_colorHandleLight );
painter->fillRect( x - 1, y, 2, 2, m_colorHandle );
}
}
return;
case PE_IndicatorToolBarSeparator:
painter->setPen( m_colorSeparator );
if ( option->state & State_Horizontal )
painter->drawLine( ( option->rect.left() + option->rect.right() - 1 ) / 2, option->rect.top() + 2,
//.........这里部分代码省略.........
示例6: paintBlankPaper
void ScoreWidget::paintBlankPaper ()
{
int PaperWidth = m_paperBmp->width();
int PaperHeight = m_paperBmp->height();
const int PoolWidth = 60;
const int Pool2Width = 85;
const int maxPoolRadius = 20;
QPainter p(m_paperBmp);
if (m_landscape)
{
p.translate(PaperWidth, 0);
p.rotate(90);
qSwap(PaperWidth, PaperHeight);
}
p.setRenderHints(QPainter::Antialiasing);
QRect NewRect = QRect(0, 0, PaperWidth, PaperHeight);
QImage img(QString(":/pics/scorepaper.png"));
p.drawImage(0, 0, img);
p.setPen(Qt::black);
// Draw borders of paper
p.drawRect(NewRect);
QPoint center(PaperWidth/2, PaperHeight-PaperWidth/2);
// Diagonal lines from bottom corners to circle
p.drawLine(NewRect.bottomLeft(), center);
p.drawLine(NewRect.bottomRight(), center);
// Central vertical line
p.drawLine( center.x(), 0, center.x(), center.y() );
// External border of pool
p.drawRect(PoolWidth, 0, PaperWidth-2*PoolWidth, PaperHeight-PoolWidth);
// Border of mountain
p.drawRect(Pool2Width, 0, PaperWidth-2*Pool2Width, PaperHeight-Pool2Width);
// Player lines
p.drawLine(0, (PaperHeight-PoolWidth)/2, PoolWidth, (PaperHeight-PoolWidth)/2);
p.drawLine(PaperWidth, (PaperHeight-PoolWidth)/2, PaperWidth-PoolWidth, (PaperHeight-PoolWidth)/2);
p.drawLine(PaperWidth/2, PaperHeight, PaperWidth/2, PaperHeight-PoolWidth);
// Circle with MaxPool value
QRadialGradient g(center, maxPoolRadius, center+QPoint(-maxPoolRadius/2,-maxPoolRadius/2));
g.setColorAt(0, Qt::white);
g.setColorAt(1, qRgb(250, 250, 0));
QBrush b1(g);
p.setBrush(b1);
p.drawEllipse(center, maxPoolRadius, maxPoolRadius);
// Draw text
// MaxPool
QFont fnt(p.font());
fnt.setBold(true);
p.setFont(fnt);
p.drawText(QRect(center.x() - maxPoolRadius, center.y() - maxPoolRadius,
maxPoolRadius*2, maxPoolRadius*2), QString::number(m_model->optMaxPool), QTextOption(Qt::AlignCenter));
fnt.setBold(false);
p.setFont(fnt);
// Players' names
QBrush brush(qRgb(255, 255, 255));
p.setBrush(brush);
const QRect r1 = p.boundingRect(NewRect, Qt::AlignHCenter, m_model->player(1)->nick());
const QRect r2 = p.boundingRect(NewRect, Qt::AlignHCenter, m_model->player(2)->nick());
const QRect r3 = p.boundingRect(NewRect, Qt::AlignHCenter, m_model->player(3)->nick());
p.drawText(QRect(center.x()-r1.width()/2, center.y()+55, r1.width(), r1.height()),
m_model->player(1)->nick(), QTextOption(Qt::AlignHCenter));
drawRotatedText(p, center.x() - 30, (PaperHeight - Pool2Width + (m_landscape ? 1 : -1) * r2.width())/2,
r2.width(), r2.height(), m_landscape ? -90 : 90, m_model->player(2)->nick());
drawRotatedText(p, center.x() + 30, (PaperHeight - Pool2Width + r3.width())/2,
r3.width(), r3.height(), -90, m_model->player(3)->nick());
p.end();
}
示例7: paint
void rosterItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save();
painter->setRenderHint(QPainter::TextAntialiasing);
QVariant value = index.data(Qt::DecorationRole);
QColor selectedBg(60, 140, 222);
QColor alternateBg(239, 245, 254);
QColor selectedText(Qt::white);
QColor nameTextColor(Qt::black);
QColor statusTextColor(Qt::darkGray);
QPixmap pixmap;
if(value.type() == QVariant::Icon)
{
QIcon icon = qvariant_cast<QIcon>(value);
pixmap = icon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
}
QPen penDivision;
// if(index.row() % 2)
// painter->fillRect(option.rect, alternateBg);
if (option.state & QStyle::State_Selected)
{
painter->fillRect(option.rect, selectedBg);
// painter->fillRect(option.rect, option.palette.highlight());
// penDivision.setColor(option.palette.highlight().color());
penDivision.setColor(selectedBg);
nameTextColor = selectedText;
statusTextColor = selectedText;
}
else
{
penDivision.setColor(QColor(244, 244, 244));
}
QRect rect = option.rect;
rect.setWidth(pixmap.width());
rect.setHeight(pixmap.height());
rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2);
rect.moveLeft(rect.left() + 2);
painter->drawPixmap(rect, pixmap);
rect = option.rect;
rect.setLeft(rect.x() + pixmap.width() + 8);
rect.moveTop(rect.y() + 3);
QFont font;
painter->setFont(font);
painter->setPen(nameTextColor);
if(!index.data(Qt::DisplayRole).toString().isEmpty())
painter->drawText(rect, index.data(Qt::DisplayRole).toString());
else
painter->drawText(rect, index.data(rosterItem::BareJid).toString());
painter->setPen(statusTextColor);
rect.setTop(rect.y() + rect.height()/2);
rect.moveTop(rect.y() - 3);
QString statusText = index.data(rosterItem::StatusText).toString();
QFontMetrics fontMetrics(font);
statusText = fontMetrics.elidedText(statusText, Qt::ElideRight, rect.width() - 34);
painter->drawText(rect, statusText);
penDivision.setWidth(0);
painter->setPen(penDivision);
rect = option.rect;
QPoint left = rect.bottomLeft();
left.setX(left.x() + 4);
QPoint right = rect.bottomRight();
right.setX(right.x() - 4);
painter->drawLine(left, right);
QImage image;
value = index.data(rosterItem::Avatar);
if(value.type() == QVariant::Image)
{
image = qvariant_cast<QImage>(value);
}
pixmap = QPixmap(":/icons/resource/avatar.png");
rect = option.rect;
rect.setWidth(pixmap.width());
rect.setHeight(pixmap.height());
rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2);
rect.moveLeft(option.rect.x() + option.rect.width() - pixmap.width() - 2);
// if(image.isNull())
// painter->drawPixmap(rect, pixmap);
// else
painter->drawImage(rect, image);
painter->restore();
}
示例8: drawIntersectionContent
// When 2 selection intersects, the content of the moving selection is written
// into the selection that is stationary, at the local intersection rectangle
void CRectangularSelection::drawIntersectionContent(const QPixmap *outsideContent,
const QRect &world_outsideContentRect,
const QRect &local_outsideContentRect)
{
if (0 == outsideContent ||
!world_outsideContentRect.intersects(rectangularSelection) ||
!confirmGeometries())
{
return;
}
QRect intersectionRect = world_outsideContentRect.intersected(rectangularSelection);
QPoint inter_topLeft = intersectionRect.topLeft();
QPoint inter_bottomRight = intersectionRect.bottomRight();
if (inter_topLeft == inter_bottomRight)
{
return;
}
// determine the local target equivalent to the intersection rectangle
int target_topLeft_dx = inter_topLeft.x() - rectangularSelection.topLeft().x();
int target_topLeft_dy = inter_topLeft.y() - rectangularSelection.topLeft().y();
int target_bottomRight_dx = inter_bottomRight.x() - rectangularSelection.bottomRight().x();
int target_bottomRight_dy = inter_bottomRight.y() - rectangularSelection.bottomRight().y();
int target_topLeft_x = local_rectangularSelection.topLeft().x() + target_topLeft_dx;
int target_topLeft_y = local_rectangularSelection.topLeft().y() + target_topLeft_dy;
int target_bottomRight_x = local_rectangularSelection.bottomRight().x() + target_bottomRight_dx;
int target_bottomRight_y = local_rectangularSelection.bottomRight().y() + target_bottomRight_dy;
QPoint target_ul(target_topLeft_x, target_topLeft_y);
QPoint target_br(target_bottomRight_x, target_bottomRight_y);
QRect target_LocalRect(target_ul, target_br);
// determine the local source equivalent to the intersection rectangle
int source_topLeft_dx = inter_topLeft.x() - world_outsideContentRect.topLeft().x();
int source_topLeft_dy = inter_topLeft.y() - world_outsideContentRect.topLeft().y();
int source_bottomRight_dx = inter_bottomRight.x() - world_outsideContentRect.bottomRight().x();
int source_bottomRight_dy = inter_bottomRight.y() - world_outsideContentRect.bottomRight().y();
int source_topLeft_x = local_outsideContentRect.topLeft().x() + source_topLeft_dx;
int source_topLeft_y = local_outsideContentRect.topLeft().y() + source_topLeft_dy;
int source_bottomRight_x = local_outsideContentRect.bottomRight().x() + source_bottomRight_dx;
int source_bottomRight_y = local_outsideContentRect.bottomRight().y() + source_bottomRight_dy;
QPoint source_ul(source_topLeft_x, source_topLeft_y);
QPoint source_br(source_bottomRight_x, source_bottomRight_y);
QRect source_LocalRect(source_ul, source_br);
// draw intersected content to top layer pixmap
if (0 != topContent)
{
delete topContent;
}
topContent = new QPixmap(local_contentRect.size());
topContent->fill(Qt::white);
QPainter painter(topContent);
painter.drawPixmap(target_LocalRect, *outsideContent, source_LocalRect);
painter.end();
// debugging
//QRect debugRect0 = outsideContent->rect();
//debugRect0.adjust(15, 15, 15, 15);
//emit printSig( target_LocalRect,
// *outsideContent,
// source_LocalRect,
// QString("OUTSIDE CONTENT"));
QBitmap bmap = topContent->createMaskFromColor(Qt::white, Qt::MaskInColor);
topContent->setMask(bmap);
}
示例9: calculateGeometry
void calculateGeometry()
{
// Convert to global points
QObject* parent__ = parent();
if ( parent__ == NULL )
return;
QWidget* parent_ = static_cast< QWidget* >( parent__ );
QRect parentRect = parent_ -> geometry();
parentRect.moveTopLeft( parent_ -> mapToGlobal(QPoint(0,0)) );
QRect widgetRect( parentRect );
QLayout* layout_ = layout();
if ( layout_ != NULL )
{
QApplication::instance() -> sendPostedEvents();
layout_ -> activate();
layout_ -> update();
}
QRect normalGeometry_ = normalGeometry();
// Use normal geometry if there is any
if ( normalGeometry_.width() != 0 && normalGeometry_.height() != 0 )
{
widgetRect.setWidth( normalGeometry_.width() );
widgetRect.setHeight( normalGeometry_.height() );
}
if ( layout_ != 0 )
{
QSize sizeHint = layout_ -> sizeHint();
if ( widgetRect.height() < sizeHint.height() )
widgetRect.setHeight( sizeHint.height() );
if ( widgetRect.width() < sizeHint.width() )
widgetRect.setWidth( sizeHint.width() );
widgetRect.setSize( sizeHint );
}
QPoint bindTo;
switch(parentCornerToAnchor_)
{
default:
case Qt::TopLeftCorner:
bindTo = parentRect.topLeft(); break;
case Qt::TopRightCorner:
bindTo = parentRect.topRight(); break;
case Qt::BottomLeftCorner:
bindTo = parentRect.bottomLeft(); break;
case Qt::BottomRightCorner:
bindTo = parentRect.bottomRight(); break;
}
switch(widgetCornerToAnchor_)
{
default:
case Qt::TopLeftCorner:
widgetRect.moveTopLeft( bindTo ); break;
case Qt::TopRightCorner:
widgetRect.moveTopRight( bindTo ); break;
case Qt::BottomLeftCorner:
widgetRect.moveBottomLeft( bindTo ); break;
case Qt::BottomRightCorner:
widgetRect.moveBottomRight( bindTo ); break;
}
QDesktopWidget desktopWidget;
// If user only has one screen, ensure the popup doesn't go off screen
// If multiple screens, this could be annoying as the popup can be viewed on a 2nd screen
if ( desktopWidget.screenCount() == 1)
widgetRect = desktopWidget.screenGeometry( parent_ ).intersected( widgetRect );
setGeometry( widgetRect );
}
示例10: paint
//.........这里部分代码省略.........
valueRect.setLeft( textRect.left()+textRect.width() );
valueRect.setWidth(61);
//TODO: use a timer to only get this when required
QString valueText("-");
float navValue;
bool navValueValid = tDigitalData(tDataId( *dataTypeIter )).ValidValue( navValue );
if ( navValueValid )
{
valueText = QString("%1").arg(navValue);
}
pPainter->drawText( valueRect, Qt::AlignVCenter | Qt::AlignRight, valueText );
currentFont.setBold(false);
pPainter->setFont(currentFont);
//Units
if (navValueValid)
{
QRect unitsRect = valueRect;
unitsRect.setLeft( valueRect.left()+valueRect.width() + 5 );
unitsRect.setWidth(47);
pPainter->drawText( unitsRect, Qt::AlignVCenter | Qt::AlignLeft, tDigitalData(tDataId( *dataTypeIter )).UnitStr() );
}
//Separator
int rowY = tableRect.y() + lineOffset;
QLine rowSeparator(tableRect.x(), rowY, tableRect.right(), rowY );
pPainter->drawLine(rowSeparator);
lineOffset += lineHeight;
//Get position data
tDigitalData position( (tDataId( DATA_TYPE_POSITION )) );
tRCoord posValue(0,0);
bool posValid = position.ValidValue( posValue );
QString latitudeValue("-");
QString longitudeValue("-");
//tCoordinate posCoord = tCoordinate( posValue );
if (posValid)
{
//TODO: find out if this logic exists in a common place
double dblDeg;
int deg;
double min;
char hem;
dblDeg = RadiansToDegrees( posValue.RLat() );
hem = dblDeg < 0 ? 'S' : 'N';
dblDeg = qAbs(dblDeg);
deg = (int)dblDeg;
min = 60 * (dblDeg - deg);
//latitudeValue = QString("%1:%2'%3").arg(deg).arg(min).arg(hem);
latitudeValue = QString("%1 %2").arg( posValue.RLat()).arg(hem);
dblDeg = RadiansToDegrees( posValue.RLon() );
hem = dblDeg < 0 ? 'W' : 'E';
dblDeg = qAbs(dblDeg);
deg = (int)dblDeg;
min = 60 * (dblDeg - deg);
//longitudeValue = QString("%1:%2'%3").arg(deg).arg(min).arg(hem);
longitudeValue = QString("%1 %2").arg(posValue.RLon()).arg(hem);
}
//Lat/Lon display
QRect latTextRect = AvailableRect();
latTextRect.setTop(tableRect.bottom()+10);
latTextRect.setWidth(latTextRect.width()/2);
latTextRect.setHeight(25);
pPainter->drawText( latTextRect, Qt::AlignCenter, QString("Latitude").toUpper() ); //TODO: look at translation?
QRect latValueRect = latTextRect;
latValueRect.setTop(latTextRect.bottom());
latValueRect.setLeft(latTextRect.left()+4);
latValueRect.setWidth(latTextRect.width()-8);
latValueRect.setHeight(latTextRect.height());
pPainter->drawRect(latValueRect);
pPainter->drawText( latValueRect, Qt::AlignCenter, latitudeValue ); //TODO: look at translation?
QRect lonTextRect = latTextRect;
lonTextRect.setLeft(latTextRect.right());
lonTextRect.setTop(latTextRect.top());
lonTextRect.setWidth(latTextRect.width());
pPainter->drawText( lonTextRect, Qt::AlignCenter, QString("Longitude").toUpper() ); //TODO: look at translation?
QRect lonValueRect = lonTextRect;
lonValueRect.setTop(lonTextRect.bottom());
lonValueRect.setLeft(lonTextRect.left()+4);
lonValueRect.setWidth(lonTextRect.width()-8);
lonValueRect.setHeight(lonTextRect.height());
pPainter->drawRect(lonValueRect);
pPainter->drawText( lonValueRect, Qt::AlignCenter, longitudeValue ); //TODO: look at translation?
}
//draw bottom border
pPainter->drawLine(tableRect.bottomLeft(), tableRect.bottomRight());
}
示例11: end
bool RectPicker::end(bool ok)
{
if (!ok)//更改代码处:,正常结束后,并不停止。只有reset时候,end(false)停止选择,重置状态机
QwtPicker::end(ok);
if (!ok)
return false;
QwtPlot *plot = QwtPlotPicker::plot();
if (!plot)
return false;
const QPolygon points = selection();
if (points.count() == 0)
return false;
QwtPickerMachine::SelectionType selectionType =
QwtPickerMachine::NoSelection;
if (stateMachine())
selectionType = stateMachine()->selectionType();
switch (selectionType)
{
case QwtPickerMachine::PointSelection:
{
const QPointF pos = invTransform(points.first());
Q_EMIT selected(pos);
break;
}
case QwtPickerMachine::RectSelection:
{
if (points.count() >= 2)
{
const QPoint p1 = points.first();
const QPoint p2 = points.last();
QPointF pF1 = invTransform(p1);
QPointF pF2 = invTransform(p2);
const QRect rect = QRect(p1, p2).normalized();
const QRect rect11 = QRect(p1, p2);
QPoint pp1 = rect.topLeft();
QPoint pp2 = rect.bottomRight();
//const QRect rect = QRect(p1, p2);
QRectF rect1 = invTransform(rect);
QPointF topLeft = rect1.topLeft();
QPointF bottomRight = rect1.bottomRight();
Q_EMIT selected(invTransform(rect));
}
break;
}
case QwtPickerMachine::PolygonSelection:
{
QVector<QPointF> dpa(points.count());
for (int i = 0; i < points.count(); i++)
dpa[i] = invTransform(points[i]);
Q_EMIT selected(dpa);
}
default:
break;
}
return ok;
}
示例12: if
void
MpcToolbarStyle::drawControl(ControlElement control, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const
{
if(control == CE_ToolBar)
{
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
QRect rect = option->rect;
if( toolbar->toolBarArea == Qt::BottomToolBarArea &&
toolbar->positionOfLine == QStyleOptionToolBar::End )
{
painter->setPen(QPen(option->palette.light().color()));
painter->drawLine(rect.topLeft().x(),
rect.topLeft().y(),
rect.topRight().x(),
rect.topRight().y());
painter->setPen(QPen(option->palette.light().color()));
painter->drawLine(rect.topLeft().x(),
rect.topLeft().y(),
rect.bottomLeft().x(),
rect.bottomLeft().y());
painter->setPen(QPen(option->palette.dark().color()));
painter->drawLine(rect.topRight().x(),
rect.topRight().y(),
rect.bottomRight().x(),
rect.bottomRight().y());
}
else if( toolbar->toolBarArea == Qt::BottomToolBarArea &&
toolbar->positionOfLine == QStyleOptionToolBar::Beginning )
{
painter->setPen(QPen(option->palette.light().color()));
painter->drawLine(rect.topLeft().x(),
rect.topLeft().y(),
rect.bottomLeft().x(),
rect.bottomLeft().y());
painter->setPen(QPen(option->palette.dark().color()));
painter->drawLine(rect.topRight().x(),
rect.topRight().y(),
rect.bottomRight().x(),
rect.bottomRight().y());
painter->setPen(QPen(option->palette.dark().color()));
painter->drawLine(rect.bottomLeft().x(),
rect.bottomLeft().y(),
rect.bottomRight().x(),
rect.bottomRight().y());
}
else
{
QWindowsStyle::drawControl(control,toolbar, painter, widget);
}
}
}
else
{
QWindowsStyle::drawControl(control,option, painter, widget);
}
}
示例13: mouseReleaseEvent
void DisplayWidget::mouseReleaseEvent(QMouseEvent *event)
{
QVariant v;
v.setValue(selectedTile);
switch(currentTool)
{
case t_pen:
{
model()->setData(this->indexAt(event->pos()), v);
break;
}
case t_box:
case t_hollow_box:
case t_circle:
case t_hollow_circle:
{
rubberBand->hide();
int headerHeight = this->horizontalHeader()->height();
int headerWidth = this->verticalHeader()->width();
// rubber band draws based on the displays 0,0 as origin
// indexes use inside corner of the headers as 0,0
//
// v-- this is 0,0 for rubber band
// []=================
// ||+<-- this is 0,0 for table fields
// ||
QRect selection = rubberBand->geometry().adjusted(-headerWidth, -headerHeight, -headerWidth, -headerHeight);
QModelIndex center = this->indexAt(selection.center());
QModelIndex topLeft = this->indexAt(selection.topLeft());
QModelIndex bottomRight = this->indexAt(selection.bottomRight());
// determine selections
if(currentTool == t_box)
{
for(int i = topLeft.column(); i <= bottomRight.column(); i++)
{
for(int j = topLeft.row(); j <= bottomRight.row(); j++)
{
model()->setData(model()->index(j, i), v);
}
}
}
else if(currentTool == t_hollow_box)
{
for(int i = topLeft.column(); i <= bottomRight.column(); i++)
{
model()->setData(model()->index(topLeft.row(), i), v);
model()->setData(model()->index(bottomRight.row(), i), v);
}
for(int i = topLeft.row(); i <= bottomRight.row(); i++)
{
model()->setData(model()->index(i, topLeft.column()), v);
model()->setData(model()->index(i, bottomRight.column()), v);
}
}
// currently suffer w/even diameters, index at center does not necessarily correlate to
// center of the actual circle. adjust to use diameter / 2 for calculations.
else if(currentTool == t_circle)
{
// x-radius
double a = bottomRight.column() - center.column();
// y-radius
double b = topLeft.row() - center.row();
// (x-h)^2/a^2 + (y-k)^2/b^2 <= 1
for(int i = topLeft.column(); i <= bottomRight.column(); i++)
{
for(int j = topLeft.row(); j <= bottomRight.row(); j++)
{
double topx = i - center.column();
double topy = j - center.row();
if(
(((topx * topx) / (a * a)) + ((topy * topy) / (b * b))) <= 1.0
)
{
model()->setData(model()->index(j, i), v);
}
}
}
}
else if(currentTool == t_hollow_circle)
{
// x(t) = (right - center) * cos(t) = a * cos(t)
// y(t) = (top - center) * sin(t) = b * sin(t)
int a = bottomRight.column() - center.column();
int b = topLeft.row() - center.row();
for(double d = 0.0; d <= 2 * M_PI; d+=(M_PI / 100))
{
int x = center.column() + qRound(a * cos(d));
int y = center.row() + qRound(b * sin(d));
model()->setData(model()->index(y, x), v);
}
}
break;
}
//.........这里部分代码省略.........
示例14: popupTimerDone
void QToolButtonPrivate::popupTimerDone()
{
Q_Q(QToolButton);
popupTimer.stop();
if (!menuButtonDown && !down)
return;
menuButtonDown = true;
QPointer<QMenu> actualMenu;
bool mustDeleteActualMenu = false;
if(menuAction) {
actualMenu = menuAction->menu();
} else if (defaultAction && defaultAction->menu()) {
actualMenu = defaultAction->menu();
} else {
actualMenu = new QMenu(q);
mustDeleteActualMenu = true;
for(int i = 0; i < actions.size(); i++)
actualMenu->addAction(actions.at(i));
}
repeat = q->autoRepeat();
q->setAutoRepeat(false);
bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;
#endif
QPoint p;
QRect screen = QApplication::desktop()->availableGeometry(q);
QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
QRect rect = q->rect();
if (horizontal) {
if (q->isRightToLeft()) {
if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
p = q->mapToGlobal(rect.bottomRight());
} else {
p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
}
p.rx() -= sh.width();
} else {
if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
p = q->mapToGlobal(rect.bottomLeft());
} else {
p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
}
}
} else {
if (q->isRightToLeft()) {
if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) {
p = q->mapToGlobal(rect.topRight());
} else {
p = q->mapToGlobal(rect.topLeft());
p.rx() -= sh.width();
}
} else {
if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) {
p = q->mapToGlobal(rect.topRight());
} else {
p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0));
}
}
}
p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
p.ry() += 1;
QPointer<QToolButton> that = q;
actualMenu->setNoReplayFor(q);
if (!mustDeleteActualMenu) //only if action are not in this widget
QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
actualMenu->d_func()->causedPopup.widget = q;
actualMenu->d_func()->causedPopup.action = defaultAction;
actionsCopy = q->actions(); //(the list of action may be modified in slots)
actualMenu->exec(p);
QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
if (mustDeleteActualMenu)
delete actualMenu;
else
QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
if (!that)
return;
actionsCopy.clear();
if (repeat)
q->setAutoRepeat(true);
}
示例15: paintTab
void FancyTabBar::paintTab(QPainter* painter, int tabIndex) const
{
if (!validIndex(tabIndex)) {
qWarning("invalid index");
return;
}
painter->save();
QRect rect = tabRect(tabIndex);
bool selected = (tabIndex == m_currentIndex);
if (selected) {
//background
painter->save();
QLinearGradient grad(rect.topLeft(), rect.topRight());
grad.setColorAt(0, QColor(255, 255, 255, 140));
grad.setColorAt(1, QColor(255, 255, 255, 210));
painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
painter->restore();
//shadows
painter->setPen(QColor(0, 0, 0, 110));
painter->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->setPen(QColor(0, 0, 0, 40));
painter->drawLine(rect.topLeft(), rect.bottomLeft());
//highlights
painter->setPen(QColor(255, 255, 255, 50));
painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1));
painter->setPen(QColor(255, 255, 255, 40));
painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
painter->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1));
}
QString tabText(painter->fontMetrics().elidedText(this->tabText(tabIndex), Qt::ElideMiddle, width()));
QRect tabTextRect(tabRect(tabIndex));
QRect tabIconRect(tabTextRect);
tabIconRect.adjust(+4, +4, -4, -4);
tabTextRect.translate(0, -2);
QFont boldFont(painter->font());
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
boldFont.setBold(true);
painter->setFont(boldFont);
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
int textFlags = Qt::AlignCenter | Qt::AlignBottom;
painter->drawText(tabTextRect, textFlags, tabText);
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
#ifndef Q_OS_MACOS
if (!selected) {
painter->save();
int fader = int(m_tabs[tabIndex]->fader());
QLinearGradient grad(rect.topLeft(), rect.topRight());
grad.setColorAt(0, Qt::transparent);
grad.setColorAt(0.5, QColor(255, 255, 255, fader));
grad.setColorAt(1, Qt::transparent);
// painter->fillRect(rect, grad);
// painter->setPen(QPen(grad, 1.0));
painter->fillRect(rect, QColor(255, 255, 255, fader));
painter->setPen(QPen(QColor(255, 255, 255, fader), 1.0));
painter->drawLine(rect.topLeft(), rect.topRight());
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->restore();
}
#endif
const int textHeight = painter->fontMetrics().height();
tabIconRect.adjust(0, 4, 0, -textHeight);
Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, selected ? QIcon::Selected : QIcon::Normal);
painter->translate(0, -1);
painter->drawText(tabTextRect, textFlags, tabText);
painter->restore();
}