本文整理汇总了C++中QRectF::moveBottom方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::moveBottom方法的具体用法?C++ QRectF::moveBottom怎么用?C++ QRectF::moveBottom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::moveBottom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doLayout
/**
* 功能
* 当前单元格子元素布局
*/
void WinDigitalDelegate::doLayout(const QStyleOptionViewItem & option, QRectF &valRect, QRectF &unitRect, QRectF &tagRect, QRectF &alarmRect, qreal &alarmSpan) const
{
/***********测量值***********/
valRect = option.rect;
valRect.setHeight(valRect.height()/3);
valRect.moveTop(valRect.bottom());
valRect.setRight(valRect.right() - valRect.width()/18- 3);
/************标记**********/
tagRect = valRect;
tagRect.moveBottom(tagRect.top());
tagRect.setTop(tagRect.top() + option.rect.height()/10);
/************单位***********/
unitRect = valRect;
unitRect.moveTop(unitRect.bottom());
unitRect.setRight(unitRect.right() - 15);
/*************报警标记**********/
alarmRect = unitRect;
alarmRect.setHeight(alarmRect.height()/3);
alarmRect.moveTop(alarmRect.bottom());
alarmRect.setLeft(alarmRect.center().x() - 4*alarmRect.height());
alarmRect.setWidth(alarmRect.height());
alarmSpan = alarmRect.width() * 2;
}
示例2:
QList<QRectF> Mode4::locate()
{
QList<QRectF> results;
if (rect.height() > 360){
return results;
}
QSize size = ARender::instance()->getActualSize();
QRectF init = rect;
init.moveCenter(QPointF(size.width() / 2.0, 0));
init.moveBottom(size.height()*(Config::getValue("/Danmaku/Protect", false) ? 0.85 : 1));
int stp = Config::getValue("/Danmaku/Grating", 10);
for (int height = init.top(); height >= 0; height -= stp){
init.moveTop(height);
results.append(init);
}
return results;
}
示例3: paintEvent
void CustomLabel::paintEvent(QPaintEvent *pe)
{
if ((!text().isEmpty()) &&
(textFormat() == Qt::PlainText ||
(textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
{
QPainter painter(this);
#ifndef DEBUG_CUSTOMLABEL
QRectF lr = contentsRect();
lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
QStyleOption opt;
opt.initFrom(this);
int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
if (wordWrap())
flags |= Qt::TextWordWrap;
switch (shadowType)
{
case NoShadow:
flags |= TF_NOSHADOW;
break;
case DarkShadow:
flags |= TF_DARKSHADOW;
break;
case LightShadow:
flags |= TF_LIGHTSHADOW;
break;
default:
break;
}
QString textToDraw = elidedText();
style()->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), textToDraw, QPalette::WindowText);
#else // DEBUG_CUSTOMLABEL
QTextDocument *doc = textDocument();
QAbstractTextDocumentLayout::PaintContext ctx = textDocumentPaintContext(doc);
QString shadowKey;
switch (shadowType)
{
case DarkShadow:
shadowKey = GFX_TEXTSHADOWS;
break;
case LightShadow:
shadowKey = GFX_NOTICEWIDGET;
break;
case NoShadow:
default:
break;
}
// magic numbers
int dx = -2;
int dy = -2;
// adding margins
dx += contentsMargins().left();
dy += contentsMargins().top();
# if 1 // for debug set 0
QGraphicsDropShadowEffect *shadow = qobject_cast<QGraphicsDropShadowEffect *>(GraphicsEffectsStorage::staticStorage(RSR_STORAGE_GRAPHICSEFFECTS)->getFirstEffect(shadowKey));
# else // debug shadow
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
shadow->setColor(Qt::red);
shadow->setOffset(1, 1);
# endif
if (shadow)
{
# if 0 // for "image method" set 1
QImage shadowedText(size(), QImage::Format_ARGB32_Premultiplied);
# if defined(Q_WS_MAC) && !defined(__MAC_OS_X_NATIVE_FULLSCREEN)
// TODO: fix that
shadowedText.fill(Qt::red); // DUNNO WHY!!!
# else
shadowedText.fill(Qt::transparent);
# endif
QPainter tmpPainter(&shadowedText);
tmpPainter.setRenderHint(QPainter::Antialiasing);
tmpPainter.setRenderHint(QPainter::HighQualityAntialiasing);
tmpPainter.setRenderHint(QPainter::TextAntialiasing);
tmpPainter.setRenderHint(QPainter::SmoothPixmapTransform);
tmpPainter.translate(dx, dy);
doc->documentLayout()->draw(&tmpPainter, ctx);
painter.drawImage(0, 0, shadowedText);
# else // text method
QPalette origPal = ctx.palette;
ctx.palette.setColor(QPalette::Text, shadow->color());
// draw shadow
painter.save();
painter.translate(dx + shadow->xOffset(), dy + shadow->yOffset());
doc->documentLayout()->draw(&painter, ctx);
painter.restore();
ctx.palette = origPal;
// draw text
painter.save();
painter.translate(dx, dy);
doc->documentLayout()->draw(&painter, ctx);
painter.restore();
# endif // shadow method
//.........这里部分代码省略.........
示例4: drawControls
void CreateMode::drawControls(QPainter* p)
{
if (!inItemCreation) return;
QPointF topLeft(createObjectPos.x(), createObjectPos.y());
QPointF btRight(canvasCurrCoord.x(), canvasCurrCoord.y());
QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight);
if (createObjectMode != modeDrawLine)
{
QRectF bounds = QRectF(topLeft, btRight).normalized();
//Lock Height to Width for Control Modifier for region drawing
if (modifiers==Qt::ControlModifier)
{
bounds.setHeight(bounds.width());
if (btRight.y()<topLeft.y())
bounds.moveBottom(topLeft.y());
if (btRight.x()<topLeft.x() && btRight.y()>topLeft.y())
bounds.moveTop(topLeft.y());
}
QRect localRect = m_canvas->canvasToLocal(bounds);
if (localRect.width() <= 0 || localRect.height() <= 0)
return;
p->setRenderHint(QPainter::Antialiasing);
p->save();
p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
drawColor.setAlpha(64);
p->setBrush(drawColor);
p->drawRect(localRect);
drawColor.setAlpha(255);
p->setBrush(Qt::NoBrush);
p->setPen(QPen(drawColor, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
int frameType = 0, itemType = 0;
getFrameItemTypes(itemType, frameType);
if (frameType == PageItem::Ellipse)
{
p->drawEllipse(localRect);
}
else if (createObjectMode == modeDrawArc)
{
QPainterPath path;
path.moveTo(localRect.width() / 2.0, localRect.height() / 2.0);
path.arcTo(0.0, 0.0, localRect.width(), localRect.height(), m_doc->itemToolPrefs().arcStartAngle, m_doc->itemToolPrefs().arcSweepAngle);
path.closeSubpath();
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if (createObjectMode == modeDrawRegularPolygon)
{
QPainterPath path = RegularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot, m_doc->itemToolPrefs().polyOuterCurvature);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if (createObjectMode == modeDrawSpiral)
{
QPainterPath path = SpiralPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().spiralStartAngle, m_doc->itemToolPrefs().spiralEndAngle, m_doc->itemToolPrefs().spiralFactor);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if ((createObjectMode == modeDrawShapes) && (createObjectSubMode > 1))
{
FPointArray poly;
int valCount = m_doc->ValCount;
double *vals = m_doc->ShapeValues;
for (int a = 0; a < valCount-3; a += 4)
{
if (vals[a] < 0)
{
poly.setMarker();
continue;
}
double x1 = localRect.width() * vals[a] / 100.0;
double y1 = localRect.height() * vals[a+1] / 100.0;
double x2 = localRect.width() * vals[a+2] / 100.0;
double y2 = localRect.height() * vals[a+3] / 100.0;
poly.addPoint(x1, y1);
poly.addPoint(x2, y2);
}
QPainterPath path = poly.toQPainterPath(false);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
p->restore();
}
else
{
QPoint p1 = m_canvas->canvasToLocal(topLeft);
QPoint p2 = m_canvas->canvasToLocal(btRight);
p->save();
p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p->setBrush(drawColor);
p->drawLine(p1, p2);
p->restore();
}
}
示例5: paintEvent
//.........这里部分代码省略.........
highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);
if(m_Ctx.CurPipelineState().SupportsBarriers())
{
text = lit(" ) Barriers ( ");
p.drawText(highlightLabel, text, to);
highlightLabel.setLeft(highlightLabel.left() + fm.width(text));
path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
p.fillPath(path, colors[BarrierUsage]);
p.drawPath(path);
highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);
}
text = lit(" ), and Clears ( ");
p.drawText(highlightLabel, text, to);
highlightLabel.setLeft(highlightLabel.left() + fm.width(text));
path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
p.fillPath(path, colors[ClearUsage]);
p.drawPath(path);
highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);
text = lit(" )");
p.drawText(highlightLabel, text, to);
}
PipRanges pipranges[UsageCount];
QRectF pipsRect = m_highlightingRect.marginsRemoved(uniformMargins(margin));
pipsRect.setX(pipsRect.x() + margin + m_titleWidth);
pipsRect.setHeight(triHeight + margin);
pipsRect.moveBottom(m_highlightingRect.bottom());
p.setClipRect(pipsRect);
qreal leftClip = -triRadius * 2.0;
qreal rightClip = pipsRect.width() + triRadius * 10.0;
if(!m_HistoryEvents.isEmpty())
{
for(const PixelModification &mod : m_HistoryEvents)
{
qreal pos = offsetOf(mod.eventId) + m_eidWidth / 2 - triRadius;
if(pos < leftClip || pos > rightClip)
continue;
if(mod.Passed())
pipranges[HistoryPassed].push(pos, triRadius);
else
pipranges[HistoryFailed].push(pos, triRadius);
}
}
else
{
for(const EventUsage &use : m_UsageEvents)
{
qreal pos = offsetOf(use.eventId) + m_eidWidth / 2 - triRadius;
if(pos < leftClip || pos > rightClip)
continue;
if(((int)use.usage >= (int)ResourceUsage::VS_RWResource &&
(int)use.usage <= (int)ResourceUsage::All_RWResource) ||
示例6: paintEvent
void CustomLabel::paintEvent(QPaintEvent * pe)
{
if ((!text().isEmpty()) &&
(textFormat() == Qt::PlainText ||
(textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
{
QPainter painter(this);
QRectF lr = contentsRect();
lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
QStyleOption opt;
opt.initFrom(this);
int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
if (wordWrap())
flags |= Qt::TextWordWrap;
switch (shadowType)
{
case NoShadow:
flags |= TF_NOSHADOW;
break;
case DarkShadow:
flags |= TF_DARKSHADOW;
break;
case LightShadow:
flags |= TF_LIGHTSHADOW;
break;
default:
break;
}
QString textToDraw = text();
int textWidth = lr.width();
// eliding text
// TODO: move to text change / resize event handler, make textToDraw a member
if (elideMode() != Qt::ElideNone)
{
QFontMetrics fm = fontMetrics();
if (!wordWrap())
{
textToDraw = fm.elidedText(text(), elideMode(), textWidth);
}
else if (elideMode() == Qt::ElideRight)
{
// multiline elide
int pxPerLine = fontMetrics().lineSpacing();
int lines = lr.height() / pxPerLine + 1;
#ifdef DEBUG_ENABLED
// if (lines > 1)
// {
// qDebug() << pxPerLine << lines << lr << fm.height() << font().toString();
// }
#endif
#ifdef Q_WS_MAC // mac hack, dunno why
//lines--;
// TODO: debug this!!!
#endif
QStringList srcLines = text().split("\n");
QStringList dstLines;
foreach (QString srcLine, srcLines)
{
int w = fm.width(srcLine);
if (w >= textWidth)
{
QStringList tmpList = srcLine.split(' ');
QString s;
int i = 0;
while (i < tmpList.count())
{
if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
{
if (!s.isEmpty())
{
dstLines += s;
s = QString::null;
}
}
if (!s.isEmpty())
{
s += " ";
}
s += tmpList.at(i);
i++;
}
dstLines += s;
}
else
{
dstLines += srcLine;
}
}