当前位置: 首页>>代码示例>>C++>>正文


C++ QSizeF::toSize方法代码示例

本文整理汇总了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();
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:11,代码来源:MediaPlayerPrivateQt.cpp

示例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());
 }
}
开发者ID:arleincho,项目名称:pgmodeler,代码行数:16,代码来源:visaogeralwidget.cpp

示例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;
}
开发者ID:EQ4,项目名称:guido-engine,代码行数:35,代码来源:main.cpp

示例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);
}
开发者ID:SwordElucidator,项目名称:QSanguosha-v2-AnimeMod,代码行数:7,代码来源:super-button.cpp

示例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();
}
开发者ID:Akira586,项目名称:Cockatrice,代码行数:60,代码来源:abstractcarditem.cpp

示例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);
    }
}
开发者ID:jobor,项目名称:posterazor,代码行数:30,代码来源:posterazorcore.cpp

示例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;
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:34,代码来源:SvgPatternHelper.cpp

示例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;
}
开发者ID:TritonSailor,项目名称:livepro,代码行数:29,代码来源:GLImageDrawable.cpp

示例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());
}
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:28,代码来源:CDiaryEdit.cpp

示例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();
    }
}
开发者ID:theunbelievablerepo,项目名称:dolphin2.1,代码行数:59,代码来源:kstandarditemlistwidget.cpp

示例11: renderAnnotation

void QgsHtmlAnnotation::renderAnnotation( QgsRenderContext &context, QSizeF size ) const
{
  if ( !context.painter() )
  {
    return;
  }

  mWebPage->setViewportSize( size.toSize() );
  mWebPage->mainFrame()->render( context.painter() );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:10,代码来源:qgshtmlannotation.cpp

示例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);
                }
            }
        }
    }
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:55,代码来源:qpagesetupdialog_unix.cpp

示例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 );
}
开发者ID:gvsurenderreddy,项目名称:symbiandump-mw4,代码行数:41,代码来源:wlanloginview.cpp

示例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);
}
开发者ID:LGCaerwyn,项目名称:touhoukill,代码行数:53,代码来源:window.cpp

示例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() ) );
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:22,代码来源:qwt_scale_draw.cpp


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