• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QFontMetricsF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QFontMetricsF函数的典型用法代码示例。如果您正苦于以下问题:C++ QFontMetricsF函数的具体用法?C++ QFontMetricsF怎么用?C++ QFontMetricsF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QFontMetricsF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: QFontMetricsF

QSize ULListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
{
    float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString());

    int S = QFontMetricsF(option.font).height() ;
    return QSize(w,S);
}
开发者ID:G10h4ck,项目名称:RetroShare,代码行数:7,代码来源:ULListDelegate.cpp


示例2: QFontMetricsF

QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & option/*option*/, const QModelIndex & index) const
{
    float FS = QFontMetricsF(option.font).height();
    float fact = FS/14.0 ;

    float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString());

    return QSize(w,FS*1.2);
    //return QSize(50*fact,17*fact);
}
开发者ID:N00D13,项目名称:RetroShare,代码行数:10,代码来源:BwCtrlWindow.cpp


示例3: textPen

// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- paint
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void Shape::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
	QPen textPen( getTextColor() );
	
	painter->setPen( textPen );
	painter->drawText
	(
		option->rect.x() + option->rect.width ()/2 - QFontMetricsF(painter->font()).width ( getText() )/2, 
		option->rect.y() + option->rect.height()/2 + QFontMetricsF(painter->font()).height(           )/3,
		getText()
	);
}
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:15,代码来源:Shape.cpp


示例4: RsAutoUpdatePage

TurtleRouterStatistics::TurtleRouterStatistics(QWidget *parent)
	: RsAutoUpdatePage(2000,parent)
{
	setupUi(this) ;
	
	m_bProcessSettings = false;

	_tunnel_statistics_F->setWidget( _tst_CW = new TurtleRouterStatisticsWidget() ) ; 
	_tunnel_statistics_F->setWidgetResizable(true);
	_tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	_tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	_tunnel_statistics_F->viewport()->setBackgroundRole(QPalette::NoRole);
	_tunnel_statistics_F->setFrameStyle(QFrame::NoFrame);
	_tunnel_statistics_F->setFocusPolicy(Qt::NoFocus);
	
	routertabWidget->addTab(new TurtleRouterDialog(),QString(tr("Tunnel Requests")));


        float fontHeight = QFontMetricsF(font()).height();
        float fact = fontHeight/14.0;
    frmGraph->setMinimumHeight(200*fact);
	
	// load settings
    processSettings(true);
}
开发者ID:N00D13,项目名称:RetroShare,代码行数:25,代码来源:TurtleRouterStatistics.cpp


示例5: setPos

void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), 0);
      _text->layout();

      qreal h = _text->height();
      if (_text->empty()) {
            QFontMetricsF fm = QFontMetricsF(_text->font(), MScore::paintDevice());
            h = fm.ascent();
            }
      else
            h = _text->height();
      qreal y = topMargin() * DPMM;
#if 0
      if (_text->align() & Align::BOTTOM)
            y += h;
      else if (_text->align() & Align::VCENTER)
            y +=  h * .5;
      else
            ; // y = 0;
#endif
      _text->setPos(leftMargin() * DPMM, y);
      h += topMargin() * DPMM + bottomMargin() * DPMM;
      bbox().setRect(0.0, 0.0, system()->width(), h);

      MeasureBase::layout();  // layout LayoutBreak's
      }
开发者ID:IsaacWeiss,项目名称:MuseScore,代码行数:28,代码来源:textframe.cpp


示例6: QFontMetricsF

bool RSPermissionMatrixWidget::computeServiceAndPeer(int x,int y,uint32_t& service_id,RsPeerId& peer_id) const
{
    // 1 - make sure that x and y are on a widget

    float S = QFontMetricsF(font()).height();

    x -= matrix_start_x ;
    y -= S*fMATRIX_START_Y ;

    if(x < 0 || x >= service_ids.size() * S*fCOL_SIZE) return false ;
    if(y < 0 || y >= peer_ids.size()    * S*fROW_SIZE) return false ;

    if( (x % (int)(S*fCOL_SIZE)) < (S*fCOL_SIZE - S*fICON_SIZE_X)/2) return false ;
    if( (x % (int)(S*fCOL_SIZE)) > (S*fCOL_SIZE + S*fICON_SIZE_X)/2) return false ;

    if( (y % (int)(S*fROW_SIZE)) < (S*fROW_SIZE - S*fICON_SIZE_Y)/2) return false ;
    if( (y % (int)(S*fROW_SIZE)) > (S*fROW_SIZE + S*fICON_SIZE_Y)/2) return false ;

    // 2 - find which widget, by looking into the service perm matrix

    service_id = service_ids[x / (int)(S*fCOL_SIZE)] ;
    peer_id = peer_ids[y / (int)(S*fCOL_SIZE)] ;

    return true ;
}
开发者ID:G10h4ck,项目名称:RetroShare,代码行数:25,代码来源:RSPermissionMatrixWidget.cpp


示例7: if

QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
{
    if (column == idColumn()) 
    {
	    if (role == Qt::ToolTipRole)
	    {
		    QString t = RSTreeWidgetItem::data(column, role).toString();
		    QImage pix;

		    if(mId.isNull())
			    return RSTreeWidgetItem::data(column, role);
		    else if(rsReputations->isIdentityBanned(mId))
			    pix = QImage(BANNED_IMAGE) ;
		    else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) 
			    pix = GxsIdDetails::makeDefaultIcon(mId);

		    int S = QFontMetricsF(font(column)).height();

		    QString embeddedImage;
		    if (RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S)) {
			    t = "<table><tr><td>" + embeddedImage + "</td><td>" + t + "</td></table>";
		    }

		    return t;
	    }
    }

    return RSTreeWidgetItem::data(column, role);
}
开发者ID:andy737,项目名称:RetroShare,代码行数:29,代码来源:GxsIdTreeWidgetItem.cpp


示例8: imageDrawText

void tst_QStaticText::drawUnderlinedText()
{
    QPixmap imageDrawText(1000, 1000);
    QPixmap imageDrawStaticText(1000, 1000);

    imageDrawText.fill(Qt::white);
    imageDrawStaticText.fill(Qt::white);

    QString s = QString::fromLatin1("Foobar");

    QFont font;
    font.setUnderline(true);

    {
        QPainter p(&imageDrawText);
        p.setFont(font);
        p.drawText(QPointF(50, 50), s);
    }

    {
        QPainter p(&imageDrawStaticText);
        QStaticText text = QStaticText(s);
        p.setFont(font);
        p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text);
    }

#if defined(DEBUG_SAVE_IMAGE)
    imageDrawText.save("drawUnderlinedText_imageDrawText.png");
    imageDrawStaticText.save("drawUnderlinedText_imageDrawStaticText.png");
#endif

    QCOMPARE(imageDrawText, imageDrawStaticText);
}
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:33,代码来源:tst_qstatictext.cpp


示例9: QFontMetricsF

void RSGraphWidget::paintLegend()
{
  //int bottom = _rec.height();

  std::vector<QPointF> vals ;
  _source->getCurrentValues(vals) ;
  int j=0;

    float FS = QFontMetricsF(font()).height();
    float fact = FS/14.0 ;

    for(uint i=0;i<vals.size();++i)
      if( _masked_entries.find(_source->displayName(i).toStdString()) == _masked_entries.end() )
      {
          if( _rec.width() - (vals[i].x()-0)*_time_scale < SCALE_WIDTH*fact )
              continue ;

          qreal paintStep = 4*fact+FS;
          qreal pos = 15*fact+j*paintStep;
          QString text = _source->legend(i,vals[i].y()) ;

          QPen oldPen = _painter->pen();
          _painter->setPen(QPen(getColor(i), Qt::SolidLine));
          _painter->drawLine(QPointF(SCALE_WIDTH*fact+10.0*fact, pos+FS/3),  QPointF(SCALE_WIDTH*fact+30.0*fact, pos+FS/3));
          _painter->setPen(oldPen);

          _painter->setPen(SCALE_COLOR);
          _painter->drawText(QPointF(SCALE_WIDTH *fact+ 40*fact,pos + 0.5*FS), text) ;

          ++j ;
      }
}
开发者ID:cavebeat,项目名称:RetroShare,代码行数:32,代码来源:RSGraphWidget.cpp


示例10: qMin

//--------------------------------------------------------------------------------------------------
//	FUNCTION: paint
//--------------------------------------------------------------------------------------------------
void QProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;
	if (std::isnan(progress) || progress <= 0.0 || progress >= 100.0)
	{
		QStyledItemDelegate::paint(painter, option, index);
	}
	else
	{
		const QFontMetrics &fm = option.fontMetrics;
		auto height = qMin(qCeil(QFontMetricsF(fm).height()) + 2, option.rect.height());
		int adjust = (option.rect.height() - height) / 2;

		double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;

		QStyleOptionProgressBar progressBarOption;
		progressBarOption.rect = option.rect.adjusted(2, adjust, -2, -adjust);
		progressBarOption.rect.setWidth(option.rect.width() - 2 * 2);
		progressBarOption.minimum = 0;
		progressBarOption.maximum = 100;
		progressBarOption.progress = progress;

		if (option.state & QStyle::State_Selected)
		{
			painter->setBrush(option.palette.highlightedText());
		}

		QApplication::style()->drawControl(QStyle::CE_ProgressBar,
			&progressBarOption, painter);
	}
}
开发者ID:kclouden,项目名称:gtest-runner,代码行数:34,代码来源:executableModelDelegate.cpp


示例11: 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());
}
开发者ID:zdimension,项目名称:CEmu,代码行数:33,代码来源:rectkey.cpp


示例12: QFontMetricsF

void QQuickFontMetrics::setFont(const QFont &font)
{
    if (m_font != font) {
        m_font = font;
        m_metrics = QFontMetricsF(m_font);
        emit fontChanged(m_font);
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:8,代码来源:qquickfontmetrics.cpp


示例13: QFontMetricsF

const QRectF QtRoundedEditRectItem::GetTextRect(const std::string& s) const
{
  const double h = QFontMetricsF(m_font).height();
  const double w = QFontMetricsF(m_font).width(s.c_str());
  //return QRectF(-0.5 * w,0.0,w,h).adjusted(0.0,0.0,2.0,-1.0); //BUG 2013-01-20
  #ifdef _WIN32
  //adjusted(0.0,0.0,2.0,0.0) works fine for 50% of the fonts supplied by Wine under native Lubuntu
  //adjusted(0.0,0.0,3.0,0.0) works fine for 80% of the fonts supplied by Wine under native Lubuntu
  return QRectF(-0.5 * w, 0.0,w,h).adjusted(0.0,0.0,3.0,0.0);
  #else
  //adjusted(0.0,0.0,2.0,-1.0) works fine for 90% of the fonts under native Lubuntu
  //adjusted(0.0,0.0,3.0,-1.0) works fine for 99% of the fonts under native Lubuntu
  //adjusted(0.0,0.0,4.0,-1.0) works fine for all the fonts I've tried under native Lubuntu
  return QRectF(-0.5 * w,0.0,w,h).adjusted(0.0,0.0,2.0,-1.0);
  #endif


}
开发者ID:markwiering,项目名称:ProjectRichelBilderbeek,代码行数:18,代码来源:qtroundededitrectitem.cpp


示例14: QFont

void TextSymbol::updateQFont()
{
	qfont = QFont();
	qfont.setBold(bold);
	qfont.setItalic(italic);
	qfont.setUnderline(underline);
	qfont.setPixelSize(internal_point_size);
	qfont.setFamily(font_family);
	qfont.setHintingPreference(QFont::PreferNoHinting);
	qfont.setKerning(kerning);
	metrics = QFontMetricsF(qfont);
	qfont.setLetterSpacing(QFont::AbsoluteSpacing, metrics.width(" ") * character_spacing);
	
	qfont.setStyleStrategy(QFont::ForceOutline);

	metrics = QFontMetricsF(qfont);
	tab_interval = 8.0 * metrics.averageCharWidth();
}
开发者ID:999999333,项目名称:mapper,代码行数:18,代码来源:symbol_text.cpp


示例15: QWidget

GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
	: QWidget(parent)
{
    float size = QFontMetricsF(font()).height() ;
    float fact = size/14.0 ;

    maxWidth = 400*fact ;
	maxHeight = 0 ;
}
开发者ID:uhml,项目名称:RetroShare,代码行数:9,代码来源:GlobalRouterStatistics.cpp


示例16: QWidget

GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
	: QWidget(parent)
{
    float size = QFontMetricsF(font()).height() ;
    float fact = size/14.0 ;

    maxWidth = 400*fact ;
	maxHeight = 0 ;
    mCurrentN = PARTIAL_VIEW_SIZE/2+1 ;
}
开发者ID:heini,项目名称:RetroShare,代码行数:10,代码来源:GlobalRouterStatistics.cpp


示例17: Q_UNUSED

void
OverlayWidget::paintEvent( QPaintEvent* event )
{
    Q_UNUSED( event );

    QPoint center( ( m_parent->width() - width() ) / 2, ( m_parent->height() - height() ) / 2 );
    if ( center != pos() )
    {
        move( center );
        return;
    }

    QPainter p( this );
    QRect r = contentsRect();

    p.setBackgroundMode( Qt::TransparentMode );
    p.setRenderHint( QPainter::Antialiasing );
    p.setOpacity( m_opacity );

    QPen pen( palette().dark().color(), .5 );
    p.setPen( pen );
    p.setBrush( QColor( 30, 30, 30, 255.0 * OPACITY ) );

    p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );

    QTextOption to( Qt::AlignCenter );
    to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );

    // shrink to fit if needed
    QFont f( font() );
    f.setPointSize( FONT_SIZE );
    f.setBold( true );

    QRectF textRect = r.adjusted( 8, 8, -8, -8 );
    qreal availHeight = textRect.height();

    QFontMetricsF fm( f );
    qreal textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
    while( textHeight > availHeight )
    {
        if( f.pointSize() <= 4 ) // don't try harder
            break;

        f.setPointSize( f.pointSize() - 1 );
        fm = QFontMetricsF( f );
        textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
    }

    p.setFont( f );
    p.setPen( palette().highlightedText().color() );
    p.drawText( r.adjusted( 8, 8, -8, -8 ), text(), to );
}
开发者ID:MechanisM,项目名称:tomahawk,代码行数:52,代码来源:overlaywidget.cpp


示例18: getOptions

void ContentBlockingInformationWidget::updateState()
{
	m_icon = (isCustomized() ? getOptions().value(QLatin1String("icon")).value<QIcon>() : QIcon());

	if (m_icon.isNull())
	{
		m_icon = ThemesManager::createIcon(QLatin1String("content-blocking"));
	}

	const int iconSize(this->iconSize().width());
	const int fontSize(qMax((iconSize / 2), 12));
	QFont font(this->font());
	font.setBold(true);
	font.setPixelSize(fontSize);

	QString label;

	if (m_amount > 999999)
	{
		label = QString::number(m_amount / 1000000) + QLatin1Char('M');
	}
	else if (m_amount > 999)
	{
		label = QString::number(m_amount / 1000) + QLatin1Char('K');
	}
	else
	{
		label = QString::number(m_amount);
	}

	const qreal labelWidth(QFontMetricsF(font).width(label));

	font.setPixelSize(fontSize * 0.8);

	QRectF rectangle((iconSize - labelWidth), (iconSize - fontSize), labelWidth, fontSize);
	QPixmap pixmap(m_icon.pixmap(iconSize, iconSize, (m_isContentBlockingEnabled ? QIcon::Normal : QIcon::Disabled)));
	QPainter iconPainter(&pixmap);
	iconPainter.fillRect(rectangle, (m_isContentBlockingEnabled ? Qt::darkRed : Qt::darkGray));
	iconPainter.setFont(font);
	iconPainter.setPen(QColor(255, 255, 255, 230));
	iconPainter.drawText(rectangle, Qt::AlignCenter, label);

	m_icon = QIcon(pixmap);

	setText(getText());
	setToolTip(text());
	setIcon(m_icon);

	m_elementsMenu->setEnabled(m_amount > 0);
}
开发者ID:Chocimier,项目名称:otter-browser,代码行数:50,代码来源:ContentBlockingInformationWidget.cpp


示例19: renderHead

    virtual void renderHead(QPainter & painter, TuringMachine const & tm) const
    {
        (void)tm;
        QFont labelFont;
        qreal fontScale = 7. / QFontMetricsF(labelFont).ascent();
        labelFont.setPointSizeF(labelFont.pointSizeF() * fontScale);

        painter.save();
        painter.setFont(labelFont);
        painter.scale(1. / 4., 1. / 4.);
        painter.setPen(QPen(Qt::black, 0., Qt::SolidLine));
        painter.setBrush(Qt::black);
        painter.drawText(-5, 2, 10, 8, Qt::AlignHCenter, label());
        painter.restore();
    }
开发者ID:evaristeg,项目名称:turingmachine,代码行数:15,代码来源:Sieve.cpp


示例20: QFontMetricsF

QRectF NMGChartYAxis::boundingRect() const
{
  if(currentWidthIntoScene <= 0 || currentHeightIntoScene <= 0) return QRectF();
  else 
  {
    if(location == NMGChartAxis::EXTERNAL)
    {
      double extraHeight = QFontMetricsF(currentFont).height()/2.0;
      return QRectF(0, -extraHeight, 
                    currentWidthIntoScene, extraHeight + currentHeightIntoScene + extraHeight);
    }
    else // INTERNAL
      return QRectF(0, 0, currentWidthIntoScene, currentHeightIntoScene);
  }
}
开发者ID:Shwe-123,项目名称:netmeter,代码行数:15,代码来源:nmgchartitem.cpp



注:本文中的QFontMetricsF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QGLFormat函数代码示例发布时间:2022-05-30
下一篇:
C++ QFontMetrics函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap