这篇教程C++ textRect函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中textRect函数的典型用法代码示例。如果您正苦于以下问题:C++ textRect函数的具体用法?C++ textRect怎么用?C++ textRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了textRect函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ifvoidHTGAvatarView::_UpdateCounter(){ char counterString[32]; int symbolsLeft = NUMBER_OF_ALLOWED_CHARS; /*Calculate the number of characters left*/ int utf8length = 0; uchar c; for(int i=0; (c=fMessage->ByteAt(i))!='/0'; i++) { if ((c&0x80) == 0) { // UTF-8 single byte char utf8length++; } else if ((c&0xc0) != 0x80) { // first byte of UTF-8 multi byte character utf8length++; } } symbolsLeft -= utf8length; sprintf(counterString, "%i", symbolsLeft); /*Check symbolsLeft, disable/enable post button and change counter color.*/ if(symbolsLeft < 0) { fCounterView->SetHighColor(255, 0, 0); fPostButton->SetEnabled(false); } else if(symbolsLeft < 140) { fCounterView->SetHighColor(128, 128, 128); fPostButton->SetEnabled(true); if(displayAvatar) { displayAvatar = false; Invalidate(); AddChild(fPostButton); AddChild(fCounterView); ResizeTo(Bounds().Width(), 83); BPoint buttonPoint(Frame().right-55, Frame().top+1+kMargin); BPoint counterPoint(Frame().right-40, Frame().top+1+kMargin+fPostButton->Bounds().Height()); fPostButton->MoveTo(buttonPoint); fCounterView->MoveTo(counterPoint); ((HTGMainWindow *)Window())->AvatarViewResized(); BRect textRect(5,22,Bounds().right-60,65); fMessage->ResizeTo(textRect.Width(), textRect.Height()); } } else if(symbolsLeft >= 140) { fPostButton->SetEnabled(false); ResizeTo(Bounds().Width(), 52); ((HTGMainWindow *)Window())->AvatarViewResized(); BRect textRect(5,22,Bounds().right-60,45); displayAvatar = true; Invalidate(); fPostButton->RemoveSelf(); fCounterView->RemoveSelf(); fMessage->ResizeTo(textRect.Width(), textRect.Height()); } fCounterView->SetText(counterString);}
开发者ID:Akujiism,项目名称:haikutwitter,代码行数:58,
示例2: Q_UNUSEDvoid GraphicsAngleItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget){ Q_UNUSED(widget); qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); if (lod > lodThreshold_) { painter->save(); painter->fillRect(boundingRect(), color_); if (lod > textLodThreshold_) { painter->setPen(QPen(QColor(Qt::gray), 0)); painter->drawRect(boundingRect()); painter->setPen(QPen(QColor(Qt::black))); int precision = std::min(static_cast<int>(lod / 8.0), 5); QString text = QString::number(value_, 'g', precision); QFont font("Times"); font.setStyleStrategy(QFont::ForceOutline); painter->setFont(font); qreal scaleCoeff = 1.0 / lod; painter->scale(scaleCoeff, scaleCoeff); QRectF textRect(0, 0, width_ / scaleCoeff, height_ / scaleCoeff); painter->drawText(textRect, Qt::AlignCenter, text); } painter->restore(); }}
开发者ID:KimuraRyo,项目名称:BSDFProcessor,代码行数:34,
示例3: sizesvoid BarChartWidget::drawBars(QPainter &painter) { std::vector<int> sizes(BAR_COUNT, 0); fillSizes(sizes); QRect baseRectangle = rect(); int activeWidth = (int) std::floor( baseRectangle.width() * (1 - 2 * PADDING) ); int singleBarWidth = (int) std::floor((activeWidth - (BAR_COUNT + 1) * SPACING) / BAR_COUNT); int baseLineY = (int) std::floor(baseRectangle.bottom() - PADDING_BOTTOM); int currX = (int) std::floor(baseRectangle.left() + baseRectangle.width() * PADDING); currX += SPACING; for (int i = 0; i < BAR_COUNT; i++) { QPoint pointTopLeft(currX, baseLineY - sizes.at((unsigned long) i)); QPoint pointBottomRight(currX + singleBarWidth, baseLineY - 1); QRect bar(pointTopLeft, pointBottomRight); painter.setPen(mainColor); painter.drawRect(bar); painter.fillRect(bar, barColor); QPoint textTopLeft(currX, baseLineY); QPoint textBottomRight(currX + singleBarWidth, baseRectangle.bottom()); QRect textRect(textTopLeft, textBottomRight); painter.setPen(mainColor); painter.drawText(textRect, Qt::AlignCenter, labels->at((unsigned long) i)); QPoint valueTopLeft(currX, baseLineY - sizes.at((unsigned long) i) - VALUE_LABEL_HEIGHT); QPoint valueBottomRight(currX + singleBarWidth, baseLineY); QRect valueLabelRect(valueTopLeft, valueBottomRight); QString textValue = QString::number(values->at((unsigned long) i)); painter.drawText(valueLabelRect, Qt::AlignHCenter | Qt::AlignTop, textValue); currX += singleBarWidth + SPACING; }}
开发者ID:ivanBobrov,项目名称:LabCodes,代码行数:35,
|