本文整理汇总了C++中QSGNode::prependChildNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QSGNode::prependChildNode方法的具体用法?C++ QSGNode::prependChildNode怎么用?C++ QSGNode::prependChildNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSGNode
的用法示例。
在下文中一共展示了QSGNode::prependChildNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updatePaintNode
QSGNode* BrowserUtils::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData)
{
Q_UNUSED(updatePaintNodeData);
if (!(m_webview && (flags() & QQuickItem::ItemHasContents))) {
return oldNode;
}
setFlag(QQuickItem::ItemHasContents, false);
#if 0
QQuickWebPage* page = m_webview->page();
qreal xmin = qMin(page->width(), m_webview->width());
qreal ymin = qMin(m_webview->height(), page->height());
#else
// Here the screenshot of the page might be too large if the page is tiny
qreal xmin = m_webview->width();
qreal ymin = m_webview->height();
#endif
ymin = qMin(static_cast<int>(ymin), m_imageSize.height());
xmin = qMin(static_cast<int>(xmin), m_imageSize.width());
QSize size(xmin, ymin);
QSGNode* node = QQuickItemPrivate::get(m_webview)->itemNode();
QSGNode* parent = node->QSGNode::parent();
QSGNode* previousSibling = node->previousSibling();
if (parent) {
parent->removeChildNode(node);
}
QSGRootNode root;
root.appendChildNode(node);
QSGRenderer* renderer;
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
renderer = QQuickItemPrivate::get(this)->sceneGraphContext()->createRenderer();
#else
renderer = QQuickItemPrivate::get(this)->sceneGraphRenderContext()->createRenderer();
#endif
renderer->setRootNode(static_cast<QSGRootNode*>(&root));
QOpenGLFramebufferObject fbo(size);
renderer->setDeviceRect(size);
renderer->setViewportRect(size);
renderer->setProjectionMatrixToRect(QRectF(QPointF(), size));
renderer->setClearColor(Qt::transparent);
renderer->renderScene(BindableFbo(&fbo));
fbo.release();
QImage image = fbo.toImage().scaled(m_imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QFileInfo imageInfo(m_outFile);
QDir imageDir(imageInfo.path());
if (!imageDir.exists()) {
imageDir.mkpath(".");
}
bool saved = image.save(m_outFile);
root.removeChildNode(node);
renderer->setRootNode(0);
delete renderer;
if (parent) {
if (previousSibling) {
parent->insertChildNodeAfter(node, previousSibling);
} else {
parent->prependChildNode(node);
}
}
Q_EMIT webViewSaved(saved, m_outFile);
return oldNode;
}