本文整理汇总了C++中QSizeF::toSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizeF::toSize方法的具体用法?C++ QSizeF::toSize怎么用?C++ QSizeF::toSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizeF
的用法示例。
在下文中一共展示了QSizeF::toSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nativeSizeChanged
void MediaPlayerPrivateQt::nativeSizeChanged(const QSizeF& size)
{
LOG(Media, "MediaPlayerPrivateQt::naturalSizeChanged(%dx%d)",
size.toSize().width(), size.toSize().height());
if (!size.isValid())
return;
m_naturalSize = size.toSize();
m_webCorePlayer->sizeChanged();
}
示例2: redimensionarVisaoGeral
//-----------------------------------------------------------
void VisaoGeralWidget::redimensionarVisaoGeral(void)
{
if(viewp)
{
QSizeF tam;
//Redimensiona o widget conforme as dimensões da cena
tam=cena->sceneRect().size();
tam.setWidth(tam.width() * FATOR_REDIM);
tam.setHeight(tam.height() * FATOR_REDIM);
this->resize(tam.toSize());
this->setMaximumSize(tam.toSize());
this->setMinimumSize(tam.toSize());
}
}
示例3: main
int main(int argc , char* argv[])
{
QApplication app( argc , argv );
//Guido Engine initialization
QGuidoPainter::startGuidoEngine();
//Create a QGuidoPainter...
QGuidoPainter * p = QGuidoPainter::createGuidoPainter();
//...and give it some Guido Music Notation
p->setGMNCode( "[c/8 d e g e d c]" );
//Get the size of the score's first and only page
int pageIndex = 1;
QSizeF s = p->pageSizeMM( pageIndex );
//Create a blank image, using the size of the score
QImage image( s.toSize() * 10 ,
QImage::Format_ARGB32 );
image.fill( QColor(Qt::white).rgb() );
//Draw on the QImage with the QGuidoPainter, via a QPainter
QPainter painter( &image );
p->draw( &painter , pageIndex , image.rect() );
QGuidoPainter::destroyGuidoPainter( p );
//Destroy the Guido Engine resources
QGuidoPainter::stopGuidoEngine();
//Save the score
image.save( "myScore.png" );
return 0;
}
示例4: label
SuperButton::SuperButton(const QString &label, const QSizeF &size, const QString file_name, Qt::AlignmentFlag flag)
: label(label), size(size), mute(true), font(Config.SmallFont)
{
title = QPixmap(size.toSize());
outimg = QImage(size.toSize(), QImage::Format_ARGB32);
init(file_name, flag);
}
示例5: paintPicture
void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle)
{
qreal scaleFactor = translatedSize.width() / boundingRect().width();
CardInfo *imageSource = facedown ? db->getCard() : info;
QPixmap *translatedPixmap = imageSource->getPixmap(translatedSize.toSize());
painter->save();
QColor bgColor = Qt::transparent;
if (translatedPixmap) {
painter->save();
transformPainter(painter, translatedSize, angle);
painter->drawPixmap(QPointF(0, 0), *translatedPixmap);
painter->restore();
} else {
QString colorStr;
if (!color.isEmpty())
colorStr = color;
else if (info->getColors().size() > 1)
colorStr = "m";
else if (!info->getColors().isEmpty())
colorStr = info->getColors().first().toLower();
if (colorStr == "b")
bgColor = QColor(0, 0, 0);
else if (colorStr == "u")
bgColor = QColor(0, 140, 180);
else if (colorStr == "w")
bgColor = QColor(255, 250, 140);
else if (colorStr == "r")
bgColor = QColor(230, 0, 0);
else if (colorStr == "g")
bgColor = QColor(0, 160, 0);
else if (colorStr == "m")
bgColor = QColor(250, 190, 30);
else
bgColor = QColor(230, 230, 230);
}
painter->setBrush(bgColor);
QPen pen(Qt::black);
pen.setWidth(2);
painter->setPen(pen);
painter->drawRect(QRectF(1, 1, CARD_WIDTH - 2, CARD_HEIGHT - 2));
if (!translatedPixmap || settingsCache->getDisplayCardNames() || facedown) {
painter->save();
transformPainter(painter, translatedSize, angle);
painter->setPen(Qt::white);
painter->setBackground(Qt::black);
painter->setBackgroundMode(Qt::OpaqueMode);
QString nameStr;
if (facedown)
nameStr = "# " + QString::number(id);
else
nameStr = name;
painter->drawText(QRectF(3 * scaleFactor, 3 * scaleFactor, translatedSize.width() - 6 * scaleFactor, translatedSize.height() - 6 * scaleFactor), Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere, nameStr);
painter->restore();
}
painter->restore();
}
示例6: paintPaperOnCanvas
void PosteRazorCore::paintPaperOnCanvas(PaintCanvasInterface *paintCanvas, bool paintOverlapping) const
{
const QSizeF canvasSize = paintCanvas->size();
const QSizeF paperSize = this->paperSize();
const QSizeF boxSize = previewSize(paperSize, canvasSize.toSize(), true);
const QPointF offset((canvasSize.width() - boxSize.width()) / 2.0, (canvasSize.height() - boxSize.height()) / 2.0);
const qreal UnitOfLengthToPixelfactor = boxSize.width()/paperSize.width();
const qreal borderTop = paperBorderTop() * UnitOfLengthToPixelfactor;
const qreal borderRight = paperBorderRight() * UnitOfLengthToPixelfactor;
const qreal borderBottom = paperBorderBottom() * UnitOfLengthToPixelfactor;
const qreal borderLeft = paperBorderLeft() * UnitOfLengthToPixelfactor;
const QSizeF printableAreaSize(boxSize.width() - borderLeft - borderRight, boxSize.height() - borderTop - borderBottom);
paintCanvas->drawFilledRect(QRectF(offset, boxSize), QColor(128, 128, 128));
paintCanvas->drawFilledRect(QRectF(QPointF(borderLeft, borderTop) + offset, printableAreaSize), QColor(230, 230, 230));
if (paintOverlapping) {
const qreal overlappingWidth = this->overlappingWidth() * UnitOfLengthToPixelfactor;
const qreal overlappingHeight = this->overlappingHeight() * UnitOfLengthToPixelfactor;
const Qt::Alignment overlappingPosition = this->overlappingPosition();
const qreal overlappingTop = (overlappingPosition & Qt::AlignTop)?
borderTop:boxSize.height() - borderBottom - overlappingHeight;
const qreal overlappingLeft = (overlappingPosition & Qt::AlignLeft)?
borderLeft:boxSize.width() - borderRight - overlappingWidth;
const QColor overlappingBrush(255, 128, 128);
paintCanvas->drawFilledRect(QRectF(QPointF(borderLeft, overlappingTop) + offset, QSizeF(printableAreaSize.width(), overlappingHeight)), overlappingBrush);
paintCanvas->drawFilledRect(QRectF(QPointF(overlappingLeft, borderTop) + offset, QSizeF(overlappingWidth, printableAreaSize.height())), overlappingBrush);
}
}
示例7: generateImage
QImage SvgPatternHelper::generateImage( const QRectF &objectBound, const QList<KoShape*> content )
{
KoZoomHandler zoomHandler;
QSizeF patternSize = size( objectBound );
QSizeF tileSize = zoomHandler.documentToView( patternSize );
QMatrix viewMatrix;
if( ! m_patternContentViewbox.isNull() )
{
viewMatrix.translate( -m_patternContentViewbox.x(), -m_patternContentViewbox.y() );
const qreal xScale = patternSize.width() / m_patternContentViewbox.width();
const qreal yScale = patternSize.height() / m_patternContentViewbox.height();
viewMatrix.scale( xScale, yScale );
}
// setup the tile image
QImage tile( tileSize.toSize(), QImage::Format_ARGB32 );
tile.fill( QColor( Qt::transparent ).rgba() );
// setup the painter to paint the tile content
QPainter tilePainter( &tile );
tilePainter.setClipRect( tile.rect() );
tilePainter.setWorldMatrix( viewMatrix );
//tilePainter.setRenderHint(QPainter::Antialiasing);
// paint the content into the tile image
KoShapePainter shapePainter;
shapePainter.setShapes( content );
shapePainter.paintShapes( tilePainter, zoomHandler );
return tile;
}
示例8: applyBorder
QImage GLImageDrawable::applyBorder(const QImage& sourceImg)
{
if(renderBorder() &&
m_borderWidth > 0.001)
{
QSizeF originalSizeWithBorder = sourceImg.size();
double x = m_borderWidth * 2;
originalSizeWithBorder.rwidth() += x;
originalSizeWithBorder.rheight() += x;
QImage cache(originalSizeWithBorder.toSize(),QImage::Format_ARGB32_Premultiplied);
memset(cache.scanLine(0),0,cache.byteCount());
QPainter p(&cache);
int bw = (int)(m_borderWidth / 2);
p.drawImage(bw,bw,sourceImg); //drawImage(bw,bw,sourceImg);
p.setPen(QPen(m_borderColor,m_borderWidth));
p.drawRect(sourceImg.rect().adjusted(bw,bw,bw,bw)); //QRectF(sourceImg.rect()).adjusted(-bw,-bw,bw,bw));
m_imageWithBorder = cache;
return cache;
}
if(!m_imageWithBorder.isNull())
m_imageWithBorder = QImage();
return sourceImg;
}
示例9: slotPrintPreview
void CDiaryEdit::slotPrintPreview()
{
CDiaryEditLock lock(this);
collectData();
QPrinter printer;
QPrintDialog dialog(&printer, this);
dialog.setWindowTitle(tr("Print Diary"));
if (dialog.exec() != QDialog::Accepted)
return;
QTextDocument doc;
QSizeF pageSize = printer.pageRect(QPrinter::DevicePixel).size();
doc.setPageSize(pageSize);
draw(doc);
if(checkAddMap->isChecked())
{
QImage img;
theMainWindow->getCanvas()->print(img, pageSize.toSize() - QSize(10,10));
doc.rootFrame()->lastCursorPosition().insertImage(img);
}
doc.print(&printer);
textEdit->clear();
textEdit->document()->setTextWidth(textEdit->size().width() - 20);
draw(*textEdit->document());
}
示例10: updateTextsCache
void KStandardItemListWidget::updateTextsCache()
{
QTextOption textOption;
switch (m_layout) {
case IconsLayout:
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
textOption.setAlignment(Qt::AlignHCenter);
break;
case CompactLayout:
case DetailsLayout:
textOption.setAlignment(Qt::AlignLeft);
textOption.setWrapMode(QTextOption::NoWrap);
break;
default:
Q_ASSERT(false);
break;
}
qDeleteAll(m_textInfo);
m_textInfo.clear();
for (int i = 0; i < m_sortedVisibleRoles.count(); ++i) {
TextInfo* textInfo = new TextInfo();
textInfo->staticText.setTextFormat(Qt::PlainText);
textInfo->staticText.setPerformanceHint(QStaticText::AggressiveCaching);
textInfo->staticText.setTextOption(textOption);
m_textInfo.insert(m_sortedVisibleRoles[i], textInfo);
}
switch (m_layout) {
case IconsLayout: updateIconsLayoutTextCache(); break;
case CompactLayout: updateCompactLayoutTextCache(); break;
case DetailsLayout: updateDetailsLayoutTextCache(); break;
default: Q_ASSERT(false); break;
}
const TextInfo* ratingTextInfo = m_textInfo.value("rating");
if (ratingTextInfo) {
// The text of the rating-role has been set to empty to get
// replaced by a rating-image showing the rating as stars.
const KItemListStyleOption& option = styleOption();
QSizeF ratingSize = preferredRatingSize(option);
const qreal availableWidth = (m_layout == DetailsLayout)
? columnWidth("rating") - columnPadding(option)
: size().width();
if (ratingSize.width() > availableWidth) {
ratingSize.rwidth() = availableWidth;
}
m_rating = QPixmap(ratingSize.toSize());
m_rating.fill(Qt::transparent);
QPainter painter(&m_rating);
const QRect rect(0, 0, m_rating.width(), m_rating.height());
const int rating = data().value("rating").toInt();
KRatingPainter::paintRating(&painter, rect, Qt::AlignJustify | Qt::AlignVCenter, rating);
} else if (!m_rating.isNull()) {
m_rating = QPixmap();
}
}
示例11: renderAnnotation
void QgsHtmlAnnotation::renderAnnotation( QgsRenderContext &context, QSizeF size ) const
{
if ( !context.painter() )
{
return;
}
mWebPage->setViewportSize( size.toSize() );
mWebPage->mainFrame()->render( context.painter() );
}
示例12: paintEvent
void paintEvent(QPaintEvent *)
{
QSize pageSize = m_pageLayout.fullRectPoints().size();
QSizeF scaledSize = pageSize.scaled(width() - 10, height() - 10, Qt::KeepAspectRatio);
QRect pageRect = QRect(QPoint(0,0), scaledSize.toSize());
pageRect.moveCenter(rect().center());
qreal width_factor = scaledSize.width() / pageSize.width();
qreal height_factor = scaledSize.height() / pageSize.height();
QMarginsF margins = m_pageLayout.margins(QPageLayout::Point);
int left = qRound(margins.left() * width_factor);
int top = qRound(margins.top() * height_factor);
int right = qRound(margins.right() * width_factor);
int bottom = qRound(margins.bottom() * height_factor);
QRect marginRect(pageRect.x() + left, pageRect.y() + top,
pageRect.width() - (left + right + 1), pageRect.height() - (top + bottom + 1));
QPainter p(this);
QColor shadow(palette().mid().color());
for (int i=1; i<6; ++i) {
shadow.setAlpha(180-i*30);
QRect offset(pageRect.adjusted(i, i, i, i));
p.setPen(shadow);
p.drawLine(offset.left(), offset.bottom(), offset.right(), offset.bottom());
p.drawLine(offset.right(), offset.top(), offset.right(), offset.bottom()-1);
}
p.fillRect(pageRect, palette().light());
if (marginRect.isValid()) {
p.setPen(QPen(palette().color(QPalette::Dark), 0, Qt::DotLine));
p.drawRect(marginRect);
marginRect.adjust(2, 2, -1, -1);
p.setClipRect(marginRect);
QFont font;
font.setPointSizeF(font.pointSizeF()*0.25);
p.setFont(font);
p.setPen(palette().color(QPalette::Dark));
QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."));
for (int i=0; i<3; ++i)
text += text;
const int spacing = pageRect.width() * 0.1;
const int textWidth = (marginRect.width() - (spacing * (m_pagePreviewColumns-1))) / m_pagePreviewColumns;
const int textHeight = (marginRect.height() - (spacing * (m_pagePreviewRows-1))) / m_pagePreviewRows;
for (int x = 0 ; x < m_pagePreviewColumns; ++x) {
for (int y = 0 ; y < m_pagePreviewRows; ++y) {
QRect textRect(marginRect.left() + x * (textWidth + spacing),
marginRect.top() + y * (textHeight + spacing),
textWidth, textHeight);
p.drawText(textRect, Qt::TextWordWrap|Qt::AlignVCenter, text);
}
}
}
}
示例13: adjustViewSize
void WlanLoginView::adjustViewSize()
{
OstTraceFunctionEntry0( WLANLOGINVIEW_ADJUSTVIEWSIZE_ENTRY );
//Store current screen size
QSizeF screenSize = mMainWindow->layoutRect().size();
//Store current content size
QSize contentSize = mWebView->page()->mainFrame()->contentsSize();
//Set viewPortSize to biggest values of content size or current screen size
QSize newViewPortSize;
if (screenSize.toSize().width() > contentSize.width()) {
newViewPortSize.setWidth(screenSize.toSize().width());
} else {
newViewPortSize.setWidth(contentSize.width());
}
if (screenSize.toSize().height() > contentSize.height()) {
newViewPortSize.setHeight(screenSize.toSize().height());
} else {
newViewPortSize.setHeight(contentSize.height());
}
mWebView->page()->setViewportSize(newViewPortSize);
//Set Web View size to same size as viewport
mWebView->setMinimumWidth((qreal)newViewPortSize.width());
mWebView->setMaximumWidth((qreal)newViewPortSize.width());
mWebView->setPreferredWidth((qreal)newViewPortSize.width());
mWebView->setMinimumHeight((qreal)newViewPortSize.height());
mWebView->setMaximumHeight((qreal)newViewPortSize.height());
mWebView->setPreferredHeight((qreal)newViewPortSize.height());
//Set preferred content size to current screen size
mWebView->page()->setPreferredContentsSize(mMainWindow->layoutRect().size().toSize());
OstTraceFunctionEntry0( WLANLOGINVIEW_ADJUSTVIEWSIZE_EXIT );
}
示例14: if
Window::Window(const QString &title, const QSizeF &size, const QString &path)
: size(size), keep_when_disappear(false)
{
setFlags(ItemIsMovable);
QPixmap *bg;
if (!path.isEmpty())
bg = new QPixmap(path);
else
bg = size.width() > size.height() ? new QPixmap("image/system/tip.png") : new QPixmap("image/system/about.png");
QImage bgimg = bg->toImage();
outimg = new QImage(size.toSize(), QImage::Format_ARGB32);
qreal pad = 10;
int w = bgimg.width(), h = bgimg.height();
int tw = outimg->width(), th = outimg->height();
qreal xc = (w - 2 * pad) / (tw - 2 * pad), yc = (h - 2 * pad) / (th - 2 * pad);
for (int i = 0; i < tw; i++) {
for (int j = 0; j < th; j++) {
int x = i, y = j;
if (x >= pad && x <= (tw - pad))
x = pad + (x - pad) * xc;
else if (x >= (tw - pad))
x = w - (tw - x);
if (y >= pad && y <= (th - pad))
y = pad + (y - pad) * yc;
else if (y >= (th - pad))
y = h - (th - y);
QRgb rgb = bgimg.pixel(x, y);
outimg->setPixel(i, j, rgb);
}
}
scaleTransform = new QGraphicsScale(this);
scaleTransform->setXScale(1.05);
scaleTransform->setYScale(0.95);
scaleTransform->setOrigin(QVector3D(boundingRect().width() / 2, boundingRect().height() / 2, 0));
QList<QGraphicsTransform *> transforms;
transforms << scaleTransform;
setTransformations(transforms);
setOpacity(0.0);
titleItem = new QGraphicsTextItem(this);
setTitle(title);
}
示例15: boundingLabelRect
/*!
Find the bounding rect for the label. The coordinates of
the rect are absolute coordinates ( calculated from pos() ).
in direction of the tick.
\param font Font used for painting
\param value Value
\sa labelRect()
*/
QRect QwtScaleDraw::boundingLabelRect( const QFont &font, double value ) const
{
QwtText lbl = tickLabel( font, value );
if ( lbl.isEmpty() )
return QRect();
const QPointF pos = labelPosition( value );
QSizeF labelSize = lbl.textSize( font );
const QTransform transform = labelTransformation( pos, labelSize );
return transform.mapRect( QRect( QPoint( 0, 0 ), labelSize.toSize() ) );
}