C

rasterwindow.h Example File

telltales/desktop/rasterwindow.h
/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Safe Renderer module ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/
#include <QtGui> #include <QImage> #include <QtSafeRenderer/qsaferenderer.h> #include <QtSafeRenderer/qsafelayout.h> #include <QtSafeRenderer/qsafewindow.h> using namespace SafeRenderer; QT_USE_NAMESPACE class ScreenBuffer : public AbstractFrameBuffer { public: ScreenBuffer(const QSafeSize& size) : m_image(size.width(), size.height(), QImage::Format_RGBA8888) { } uchar *bits() { return m_image.bits(); } quint32 bytesPerLine() { return m_image.bytesPerLine(); } QImage image() { return m_image; } uchar bitsPerPixel() { return m_image.pixelFormat().bitsPerPixel(); } PixelFormat format() const { return PixelFormat::RGBA8888; } private: QImage m_image; }; class RasterWindow : public QWindow, public AbstractWindow { Q_OBJECT public: explicit RasterWindow(const QSafeSize &size, QWindow *parent = 0); virtual void render(QPainter *painter); //Window virtual void render(); virtual AbstractFrameBuffer *buffer() { return &m_buffer; } public slots: void renderLater(); void renderNow(); protected: bool event(QEvent *event) override; void resizeEvent(QResizeEvent *event) override; void exposeEvent(QExposeEvent *event) override; private: QBackingStore *m_backingStore; ScreenBuffer m_buffer; };

Available under certain Qt licenses.
Find out more.