本文整理汇总了C++中QWebPage::viewportSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebPage::viewportSize方法的具体用法?C++ QWebPage::viewportSize怎么用?C++ QWebPage::viewportSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebPage
的用法示例。
在下文中一共展示了QWebPage::viewportSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPointerPosition
QPoint WebkitPixelStreamer::getPointerPosition(const deflect::Event &dcEvent) const
{
QWebPage* page = webView_.page();
int x = dcEvent.mouseX * page->viewportSize().width();
int y = dcEvent.mouseY * page->viewportSize().height();
x = std::max(0, std::min(x, page->viewportSize().width()-1));
y = std::max(0, std::min(y, page->viewportSize().height()-1));
return QPoint(x, y);
}
示例2: createThumbnail
void PageScreen::createThumbnail()
{
QWebPage* page = m_view->page();
const int heightLimit = 20000;
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
const QSize &originalSize = page->viewportSize();
const QSize &frameSize = page->mainFrame()->contentsSize();
const int verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width();
const int horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();
int yPosition = 0;
bool canScroll = frameSize.height() > heightLimit;
// We will split rendering page into smaller parts to avoid infinite loops
// or crashes.
do {
int remainingHeight = frameSize.height() - yPosition;
if (remainingHeight <= 0) {
break;
}
QSize size(frameSize.width(),
remainingHeight > heightLimit ? heightLimit : remainingHeight);
page->setViewportSize(size);
page->mainFrame()->scroll(0, qMax(0, yPosition - horizontalScrollbarSize));
QImage image(page->viewportSize().width() - verticalScrollbarSize,
page->viewportSize().height() - horizontalScrollbarSize,
QImage::Format_ARGB32_Premultiplied);
QPainter painter(&image);
page->mainFrame()->render(&painter);
painter.end();
m_pageImages.append(image);
canScroll = remainingHeight > heightLimit;
yPosition += size.height();
}
while (canScroll);
page->setViewportSize(originalSize);
page->mainFrame()->setScrollBarValue(Qt::Vertical, originalScrollPosition.y());
page->mainFrame()->setScrollBarValue(Qt::Horizontal, originalScrollPosition.x());
m_imageScaling = new QFutureWatcher<QImage>(this);
m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage));
connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage()));
}
示例3: createPixmap
void PageScreen::createPixmap()
{
QWebPage* page = m_view->page();
QSize originalSize = page->viewportSize();
page->setViewportSize(page->mainFrame()->contentsSize());
QImage image(page->viewportSize(), QImage::Format_ARGB32);
QPainter painter(&image);
page->mainFrame()->render(&painter);
painter.end();
m_pagePixmap = QPixmap::fromImage(image);
page->setViewportSize(originalSize);
}
示例4: viewportSize
QSize QWebPageProto::viewportSize() const
{
QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
if (item)
return item->viewportSize();
return QSize();
}
示例5: update
void WebkitPixelStreamer::update()
{
QMutexLocker locker(&mutex_);
QWebPage* page = webView_.page();
if( !page->viewportSize().isEmpty())
{
if (image_.size() != page->viewportSize())
image_ = QImage( page->viewportSize(), QImage::Format_ARGB32 );
QPainter painter( &image_ );
page->mainFrame()->render( &painter );
painter.end();
emit imageUpdated(image_);
}
}
示例6: createThumbnail
void PageScreen::createThumbnail()
{
QWebPage* page = m_view->page();
QSize originalSize = page->viewportSize();
page->setViewportSize(page->mainFrame()->contentsSize());
m_pageImage = QImage(page->viewportSize(), QImage::Format_ARGB32_Premultiplied);
QPainter painter(&m_pageImage);
page->mainFrame()->render(&painter);
painter.end();
m_verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width();
m_horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();
page->setViewportSize(originalSize);
m_imageScaling = new QFutureWatcher<QImage>(this);
connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage()));
m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage));
}
示例7: 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);
}