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


C++ QWebFrame::contentsSize方法代码示例

本文整理汇总了C++中QWebFrame::contentsSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::contentsSize方法的具体用法?C++ QWebFrame::contentsSize怎么用?C++ QWebFrame::contentsSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWebFrame的用法示例。


在下文中一共展示了QWebFrame::contentsSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
message_view::page_down()
{
  QWebFrame* frame = m_bodyv->page()->mainFrame();
  if (!frame)
    return;
  QPoint pos = frame->scrollPosition();
  int y = m_bodyv->geometry().height() + pos.y();
  if (y > frame->contentsSize().height()-frame->geometry().height())
    y = frame->contentsSize().height()-frame->geometry().height();
  pos.setY(y);
  frame->setScrollPosition(pos);
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例2: while

QWebFrame *QtScrollerFilter::scrollingFrameAt_QWebView(QWebView *view, const QPoint &pos) const
{
    if (!view->page())
         return 0;

    QWebFrame *mainFrame = view->page()->mainFrame();
    QWebHitTestResult hitTest = mainFrame->hitTestContent(pos);
    QWebFrame *hitFrame = hitTest.frame();
         
    if (!hitFrame)
        return 0;

    QRect vsbrect = hitFrame->scrollBarGeometry(Qt::Vertical);
    QRect hsbrect = hitFrame->scrollBarGeometry(Qt::Horizontal);

    if (!vsbrect.isEmpty() && vsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
        return 0;
    if (!hsbrect.isEmpty() && hsbrect.contains(hitTest.pos() - hitFrame->scrollPosition()))
        return 0;

    QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();
    
    while (hitFrame && range.width() <= 1 && range.height() <= 1)
        hitFrame = hitFrame->parentFrame();
    return hitFrame;
}
开发者ID:nhinze,项目名称:rhodes,代码行数:26,代码来源:qtscrollerfilter.cpp

示例3: contentsSize

QSize QWebFrameProto::contentsSize() const
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    return item->contentsSize();
  return QSize();
}
开发者ID:xtuple,项目名称:qt-client,代码行数:8,代码来源:qwebframeproto.cpp

示例4: loaded

void InfoView::loaded(bool ok) {
    if (!ok || !shouldShow()) {
        deleteLater();
        return;
    }
    
    QDesktopWidget* desktop = Application::getInstance()->desktop();
    QWebFrame* mainFrame = page()->mainFrame();
    
    int height = mainFrame->contentsSize().height() > desktop->height() ?
        desktop->height() * MAX_DIALOG_HEIGHT_RATIO :
        mainFrame->contentsSize().height();
    
    resize(mainFrame->contentsSize().width(), height);
    move(desktop->screen()->rect().center() - rect().center());
    setWindowTitle(title());
    setAttribute(Qt::WA_DeleteOnClose);
    show();
}
开发者ID:ey6es,项目名称:hifi,代码行数:19,代码来源:InfoView.cpp

示例5: scrollingFrameAt

    // Returns the innermost frame at the given position that can scroll.
    QWebFrame* scrollingFrameAt(const QPoint& pos) const
    {
        QWebFrame* hitFrame = 0;
        if (m_view) {
            QWebFrame* frame = m_view->page()->mainFrame();
            hitFrame = frame->hitTestContent(pos).frame();
            QSize range = hitFrame->contentsSize() - hitFrame->geometry().size();

            while (hitFrame && range.width() <= 1 && range.height() <= 1)
                hitFrame = hitFrame->parentFrame();

            return hitFrame;
        }
    }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例6: 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);
}
开发者ID:TejaswiAllam,项目名称:celerity-viewers,代码行数:14,代码来源:viewer.cpp

示例7: foreach

void
CutyCapt::saveSnapshot() {
    QWebFrame *mainFrame = mPage->mainFrame();
    
    // 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() );
    
    if (mPage->fixedWidth != 0 && mPage->fixedHeight != 0) {
      mPage->setViewportSize(QSize(mPage->fixedWidth, mPage->fixedHeight));
    }

    if (this-mPage->mSelector.count() > 0) {
        QWebElementCollection collection = mainFrame->findAllElements(this->mPage->mSelector);

        QJsonObject obj;
        QJsonArray elements;

        foreach(QWebElement elem, collection) {
            QJsonObject e;
            e["id"] = elem.attribute("id");

            if (this->mPage->mRetina) {
                e["x"] = elem.geometry().x() * 2;
                e["y"] = elem.geometry().y() * 2;
                e["width"] = elem.geometry().width() * 2;
                e["height"] = elem.geometry().height() * 2;
            }else{
                e["x"] = elem.geometry().x();
                e["y"] = elem.geometry().y();
                e["width"] = elem.geometry().width();
                e["height"] = elem.geometry().height();
            }

            elements.append(e);
        }
开发者ID:deanrock,项目名称:CutyCapt,代码行数:43,代码来源:CutyCapt.cpp

示例8: saveScreenshot

void WebPage::saveScreenshot(const QString& fileName, const QSize& vpSize)
{
  QSize originalVpSize = viewportSize();
  QWebFrame* frame = mainFrame();

  if (!vpSize.isNull()) {
    setViewportSize(vpSize);
  }

  QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
  image.fill(Qt::transparent);

  QPainter painter(&image);
  painter.setRenderHint(QPainter::Antialiasing, true);
  painter.setRenderHint(QPainter::TextAntialiasing, true);
  painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
  frame->documentElement().render(&painter);
  painter.end();

  image.save(fileName);

  setViewportSize(originalVpSize);
}
开发者ID:mlapshin,项目名称:revisor,代码行数:23,代码来源:web_page.cpp

示例9: scrollEnd

void WebView::scrollEnd()
{
    QWebFrame* frame = this->page()->mainFrame();
    frame->setScrollPosition(QPoint(0, frame->contentsSize().height()));
}
开发者ID:hytham,项目名称:qt-webkit-kiosk,代码行数:5,代码来源:webview.cpp

示例10: maximumScrollPosition

 QPoint maximumScrollPosition() const
 {
     QWebFrame* frame = currentFrame();
     QSize s = frame ? frame->contentsSize() - frame->geometry().size() : QSize(0, 0);
     return QPoint(qMax(0, s.width()), qMax(0, s.height()));
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例11: 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);
    }
  };
开发者ID:sstelfox,项目名称:CutyCapt,代码行数:67,代码来源:CutyCapt.cpp


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