本文整理汇总了C++中QTextLayout::minimumWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextLayout::minimumWidth方法的具体用法?C++ QTextLayout::minimumWidth怎么用?C++ QTextLayout::minimumWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextLayout
的用法示例。
在下文中一共展示了QTextLayout::minimumWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initCache
void KPrAttributeHeight::initCache(KPrAnimationCache *animationCache, int step, KPrShapeAnimation * shapeAnimation, qreal startValue, qreal endValue)
{
qreal v1 = 0.0, v2 = 0.0, tx = 0.0, ty = 0.0;
KoShape * shape = shapeAnimation->shape();
KoTextBlockData * textBlockData = shapeAnimation->textBlockData();
if (textBlockData) {
if (KoTextShapeData *textShapeData = dynamic_cast<KoTextShapeData*>(shape->userData())) {
QTextDocument *textDocument = textShapeData->document();
for (int i = 0; i < textDocument->blockCount(); i++) {
QTextBlock textBlock = textDocument->findBlockByNumber(i);
if (textBlock.userData() == textBlockData) {
QTextLayout *layout = textBlock.layout();
v1 = startValue * animationCache->pageSize().height() / layout->boundingRect().height();
v2 = endValue * animationCache->pageSize().height() / layout->boundingRect().height();
tx = layout->minimumWidth() * animationCache->zoom() / 2;
ty = layout->boundingRect().height() * animationCache->zoom() / 2;
}
}
}
}
else {
v1 = startValue * animationCache->pageSize().height() / shape->size().height();
v2 = endValue * animationCache->pageSize().height() / shape->size().height();
tx = shape->size().width() * animationCache->zoom() / 2;
ty = shape->size().height() * animationCache->zoom() / 2;
}
animationCache->init(step, shape, textBlockData, "transform", QTransform().translate(tx, ty).scale(1, v1).translate(-tx, -ty));
animationCache->init(step + 1, shape, textBlockData, "transform", QTransform().translate(tx, ty).scale(1, v2).translate(-tx, -ty));
}
示例2: updateCache
void KPrAttributeHeight::updateCache(KPrAnimationCache *cache, KPrShapeAnimation *shapeAnimation, qreal value)
{
qreal tx = 0.0, ty = 0.0;
KoShape * shape = shapeAnimation->shape();
KoTextBlockData * textBlockData = shapeAnimation->textBlockData();
QTransform transform;
if (textBlockData) {
if (KoTextShapeData *textShapeData = dynamic_cast<KoTextShapeData*>(shape->userData())) {
QTextDocument *textDocument = textShapeData->document();
for (int i = 0; i < textDocument->blockCount(); i++) {
QTextBlock textBlock = textDocument->findBlockByNumber(i);
if (textBlock.userData() == textBlockData) {
QTextLayout *layout = textBlock.layout();
value = value * cache->pageSize().height() / layout->boundingRect().height();
tx = layout->minimumWidth() * cache->zoom() / 2;
ty = layout->boundingRect().height() * cache->zoom() / 2;
}
}
}
}
else {
value = value * cache->pageSize().height() / shape->size().height();
tx = shape->size().width() * cache->zoom() / 2;
ty = shape->size().height() * cache->zoom() / 2;
}
transform.translate(tx, ty).scale(1, value).translate(-tx, -ty);
cache->update(shape, shapeAnimation->textBlockData(), "transform", transform);
}