本文整理汇总了C++中QWebFrame::render方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::render方法的具体用法?C++ QWebFrame::render怎么用?C++ QWebFrame::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::render方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void QWebFrameProto::render(QPainter * painter, int layer, const QRegion & clip)
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
item->render(painter, QWebFrame::RenderLayer(layer), clip);
}
示例2: renderPage
void ImageSnapView::renderPage(){
QWebFrame* frame = webView->page()->mainFrame();
if(renderedPage != 0){
delete renderedPage;
}
renderedPage = new QImage(webView->size(), QImage::Format::Format_ARGB32) ;
QPainter painter(renderedPage);
frame->render(&painter);
painter.end();
mapImageView->showImage(renderedPage);
}
示例3: renderPageTo
void Viewer::renderPageTo(QImage* image)
{
QWebPage *page = webView->page();
QWebFrame *frame = page->currentFrame();
QSize origSize = page->viewportSize();
page->setViewportSize(frame->contentsSize());
QPainter painter(image);
frame->render(&painter);
painter.end();
page->setViewportSize(origSize);
}
示例4: _q_repaintReal
void QQuickWebViewPrivate::_q_repaintReal()
{
qDebug() << Q_FUNC_INFO << "start" << repaintRect;
repaintQueued = false;
QPainter p;
if (!p.begin(&renderedPage)) {
qDebug() << "Painter error!";
return;
}
QWebFrame *frame = page->mainFrame();
frame->render(&p, QWebFrame::ContentsLayer, QRegion(repaintRect));
q->update(repaintRect);
repaintRect = QRect();
qDebug() << Q_FUNC_INFO << "end";
}
示例5: draw
void WebViewCache::draw(QPainter * painter, QGraphicsEffectSource * source)
{
const QGraphicsItem *item = source->graphicsItem();
QSizeF itemSize = item->boundingRect().size();
if (!qFuzzyCompare(itemSize.width(), m_itemSize.width()) ||
!qFuzzyCompare(itemSize.height(), m_itemSize.height())) {
qDebug() << "Refresh tile cache, for new size" << itemSize;
for (int i = 0; i < m_tilePixmaps.size(); i++) {
QPixmapCache::remove(m_tilePixmaps[i]);
}
m_tilePixmaps.clear();
m_tileRects.clear();
int itemWidth = itemSize.width() + 0.5;
int itemHeight = itemSize.height() + 0.5;
int tilesX = itemWidth / TileSideLength;
int tilesY = itemHeight / TileSideLength;
if ((itemWidth % TileSideLength) != 0) {
++tilesX;
}
if ((itemHeight % TileSideLength) != 0) {
++tilesY;
}
int tilesCount = tilesX * tilesY;
m_tilePixmaps.resize(tilesCount);
m_tileRects.resize(tilesCount);
for (int i = 0; i < tilesX; i++) {
for (int j = 0; j < tilesY; j++) {
int x = i * TileSideLength;
int y = j * TileSideLength;
m_tileRects[i + j * tilesX]
= QRectF(x, y, TileSideLength, TileSideLength);
}
}
m_itemSize = itemSize;
}
const QGraphicsItem *parentItem = item->parentItem();
QPointF itemPos = item->pos();
QRectF parentRect = parentItem->boundingRect();
for (int i = 0; i < m_tileRects.size(); i++) {
QRectF tileRect = m_tileRects[i].translated(itemPos);
if (!tileRect.intersects(parentRect) && !tileRect.contains(parentRect)) {
continue;
}
QPixmap tilePixmap;
if (!QPixmapCache::find(m_tilePixmaps[i], &tilePixmap)) {
tilePixmap = QPixmap(TileSideLength, TileSideLength);
QWebFrame *webFrame = m_webView->page()->mainFrame();
QPainter tilePainter(&tilePixmap);
tilePainter.translate(-m_tileRects[i].left(), -m_tileRects[i].top());
webFrame->render(&tilePainter, m_tileRects[i].toRect());
tilePainter.end();
m_tilePixmaps[i] = QPixmapCache::insert(tilePixmap);
}
tileRect = tileRect.translated(-itemPos);
painter->drawPixmap(tileRect.topLeft(), tilePixmap);
}
}
示例6: saveSnapshot
void CutyCapt::saveSnapshot() {
QWebFrame *mainFrame = mPage->mainFrame();
QPainter painter;
const char* format = NULL;
for (int ix = 0; CutyExtMap[ix].id != OtherFormat; ++ix) {
if (CutyExtMap[ix].id == mFormat) {
format = CutyExtMap[ix].identifier;
}
}
// TODO: sometimes contents/viewport can have size 0x0 in which case saving
// them will fail. This is likely the result of the method being called too
// early. So far I've been unable to find a workaround, except using --delay
// with some substantial wait time. I've tried to resize multiple time, make
// a fake render, check for other events... This is primarily a problem under
// my Ubuntu virtual machine.
mPage->setViewportSize( mainFrame->contentsSize() );
switch (mFormat) {
case SvgFormat: {
QSvgGenerator svg;
svg.setFileName(mOutput);
svg.setSize(mPage->viewportSize());
painter.begin(&svg);
mainFrame->render(&painter);
painter.end();
break;
}
case PdfFormat:
case PsFormat: {
QPrinter printer;
printer.setPageSize(QPrinter::A4);
printer.setOutputFileName(mOutput);
// TODO: change quality here?
mainFrame->print(&printer);
break;
}
#if QT_VERSION < 0x050000
case RenderTreeFormat:
QFile file(mOutput);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream s(&file);
s.setCodec("utf-8");
s << mainFrame->renderTreeDump();
break;
}
#endif
case InnerTextFormat:
case HtmlFormat: {
QFile file(mOutput);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream s(&file);
s.setCodec("utf-8");
s << (mFormat == InnerTextFormat ? mainFrame->toPlainText() : (mFormat == HtmlFormat ? mainFrame->toHtml() : "bug"));
break;
}
default: {
QImage image(mPage->viewportSize(), QImage::Format_ARGB32);
painter.begin(&image);
mainFrame->render(&painter);
painter.end();
// TODO: add quality
image.save(mOutput, format);
}
};