本文整理汇总了C++中QFontMetricsF函数的典型用法代码示例。如果您正苦于以下问题:C++ QFontMetricsF函数的具体用法?C++ QFontMetricsF怎么用?C++ QFontMetricsF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QFontMetricsF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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()
);
}
示例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);
}
示例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
}
示例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 ;
}
示例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);
}
示例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);
}
示例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 ;
}
}
示例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);
}
}
示例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());
}
示例12: QFontMetricsF
void QQuickFontMetrics::setFont(const QFont &font)
{
if (m_font != font) {
m_font = font;
m_metrics = QFontMetricsF(m_font);
emit fontChanged(m_font);
}
}
示例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
}
示例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();
}
示例15: QWidget
GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
: QWidget(parent)
{
float size = QFontMetricsF(font()).height() ;
float fact = size/14.0 ;
maxWidth = 400*fact ;
maxHeight = 0 ;
}