本文整理汇总了C++中QwtMetricsMap::screenToLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtMetricsMap::screenToLayout方法的具体用法?C++ QwtMetricsMap::screenToLayout怎么用?C++ QwtMetricsMap::screenToLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtMetricsMap
的用法示例。
在下文中一共展示了QwtMetricsMap::screenToLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textSize
QSize QwtText::textSize(const QFont &font) const
{
#if QT_VERSION < 0x040000
const QFont fnt(usedFont(font));
#else
// We want to calculate in screen metrics. So
// we need a font that uses screen metrics
const QFont fnt(usedFont(font), QApplication::desktop());
#endif
if ( !d_layoutCache->textSize.isValid()
|| d_layoutCache->font != fnt )
{
d_layoutCache->textSize = d_data->textEngine->textSize(
fnt, d_data->flags, d_data->text);
d_layoutCache->font = fnt;
}
QSize sz = d_layoutCache->textSize;
if ( d_data->layoutAttributes & MinimumLayout )
{
int left, right, top, bottom;
d_data->textEngine->textMargins(fnt, d_data->text,
left, right, top, bottom);
sz -= QSize(left + right, top + bottom);
}
const QwtMetricsMap map = QwtPainter::metricsMap();
sz = map.screenToLayout(sz);
return sz;
}
示例2: textSize
/*!
Returns the size, that is needed to render text
\param defaultFont Font of the text
\return Caluclated size
*/
QSize QwtText::textSize(const QFont &defaultFont) const
{
#if QT_VERSION < 0x040000
const QFont font(usedFont(defaultFont));
#else
// We want to calculate in screen metrics. So
// we need a font that uses screen metrics
const QFont font(usedFont(defaultFont), QApplication::desktop());
#endif
if ( !d_layoutCache->textSize.isValid()
|| d_layoutCache->font != font )
{
d_layoutCache->textSize = d_data->textEngine->textSize(
font, d_data->renderFlags, d_data->text);
d_layoutCache->font = font;
}
QSize sz = d_layoutCache->textSize;
const QwtMetricsMap map = QwtPainter::metricsMap();
if ( d_data->layoutAttributes & MinimumLayout )
{
int left, right, top, bottom;
d_data->textEngine->textMargins(font, d_data->text,
left, right, top, bottom);
sz -= QSize(left + right, top + bottom);
#if QT_VERSION >= 0x040000
if ( !map.isIdentity() )
{
#ifdef __GNUC__
#warning Too small text size, when printing in high resolution
#endif
/*
When printing in high resolution, the tick labels
of are cut of. We need to find out why, but for
the moment we add a couple of pixels instead.
*/
sz += QSize(3, 2);
}
#endif
}
sz = map.screenToLayout(sz);
return sz;
}