Search code examples
c++qtrenderingblit

Qt example of using offscreen rendering


I am trying to use offscreen rendering in my Qt 5.5 application. I'm looking at an example:

http://doc.qt.io/qt-5/qtquick-scenegraph-textureinthread-threadrenderer-cpp.html

One of the classes is derived from "QSGSimpleTextureNode", but when I try to include the header:

    #include <QSGSimpleTextureNode>

I get an error "No such file or directory", in the example it includes:

    include <qsgsimpletexturenode.h>

Not sure why, however what I'm trying to do is use offscreen rendering to prepare a complete bitmap ready to blit to the visible context, is there a good simple and complete example of how to do this?

Edit...bit more information, I'm trying to create a QWidget derived class that shows a compass strip, the strip will typically show the current compass heading in the centre of the strip with a specific number of ticks either side of the centre showing periodic angle positions. The full strip will be rendered in the offscreen bit map and only the part that matches the displayable screen area for the current heading will be copied to the visible area.

Project file:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2016-03-07T08:45:43
    #
    #-------------------------------------------------

    QT       += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = QtFCS
    TEMPLATE = app


    SOURCES += main.cpp\
        clsMainWin.cpp \
        clsPSstrip.cpp \
        clsSimWin.cpp

    HEADERS  += \
        clsMainWin.h \
        clsPSstrip.h \
        clsSimWin.h

    FORMS    += \
        clsMainWin.ui \
        clsSimWin.ui

Solution

  • Make sure you add quick to the .pro file so that qmake knows to include the quick related headers and libraries.