QPainter + QQuickFramebufferObject
-
I asked allready here:
https://forum.qt.io/topic/74083/qpainter-qquickframebufferobject
but nobody answers me.Is it possible to use QPainter with QQuickFramebufferObject or only with QQuickPaintedItem??? I was set renderTarget flag of QQuickPaintedItem to QQuickPaintedItem::FramebufferObject but updates still work very slow :(
Links:
https://dangelog.wordpress.com/2013/02/10/using-fbos-instead-of-pbuffers-in-qt-5-2/
http://doc.qt.io/qt-5/qtquick-scenegraph-textureinsgnode-example.html -
Or is there a way to draw just over QQuickView?
#include <QQuickView> #include <QOpenGLContext> #include <QOpenGLFramebufferObjectFormat> #include <QOpenGLPaintDevice> #include <QPainter> class MyView : public QQuickView { public: MyView() { setSurfaceType(QWindow::OpenGLSurface); } protected: bool event(QEvent *ev) { bool result = QQuickView::event(ev); // I don't know what type should be here if (ev->type() == QEvent::Expose /*?*/) { QOpenGLContext context; if (!context.create()) qFatal("Cannot create the requested OpenGL context!"); context.makeCurrent(this); const QRect drawRect(0, 0, 400, 400); const QSize drawRectSize = drawRect.size(); QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setSamples(16); fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); QOpenGLFramebufferObject fbo(drawRectSize, fboFormat); fbo.bind(); QOpenGLPaintDevice device(drawRectSize); QPainter painter; painter.begin(&device); painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); painter.fillRect(drawRect, Qt::blue); painter.end(); fbo.release(); } return result; } };
Does anyone know what's wrong here?