![]() |
CopperSpice API
1.8.1
|
The QOpenGLWindow class is a convenience subclass of QWindow to perform OpenGL painting. More...
Public Methods | |
~QOpenGLWindow () | |
![]() | |
qreal | devicePixelRatio () const |
![]() | |
QWindow (QScreen *screen=nullptr) | |
QWindow (QWindow *parent) | |
virtual | ~QWindow () |
QSize | baseSize () const |
Qt::ScreenOrientation | contentOrientation () const |
void | create () |
QCursor | cursor () const |
void | destroy () |
qreal | devicePixelRatio () const |
QString | filePath () const |
Qt::WindowFlags | flags () const |
virtual QObject * | focusObject () const |
QSurfaceFormat | format () const override |
QRect | frameGeometry () const |
QMargins | frameMargins () const |
QPoint | framePosition () const |
QRect | geometry () const |
QIcon | icon () const |
bool | isActive () const |
bool | isAncestorOf (const QWindow *child, AncestorMode mode=IncludeTransients) const |
bool | isExposed () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QRegion | mask () const |
QSize | maximumSize () const |
QSize | minimumSize () const |
Qt::WindowModality | modality () const |
QWindow * | parent () const |
QPoint | position () const |
void | reportContentOrientationChange (Qt::ScreenOrientation orientation) |
QSurfaceFormat | requestedFormat () const |
void | resize (const QSize &newSize) |
void | resize (int w, int h) |
QScreen * | screen () const |
void | setBaseSize (const QSize &size) |
void | setCursor (const QCursor &cursor) |
void | setFilePath (const QString &filePath) |
void | setFlags (Qt::WindowFlags flags) |
void | setFormat (const QSurfaceFormat &format) |
void | setFramePosition (const QPoint &point) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int posx, int posy, int w, int h) |
void | setIcon (const QIcon &icon) |
bool | setKeyboardGrabEnabled (bool grab) |
void | setMask (const QRegion ®ion) |
void | setMaximumSize (const QSize &size) |
void | setMinimumSize (const QSize &size) |
void | setModality (Qt::WindowModality modality) |
bool | setMouseGrabEnabled (bool grab) |
void | setParent (QWindow *parent) |
void | setPosition (const QPoint &pt) |
void | setPosition (int posx, int posy) |
void | setScreen (QScreen *screen) |
void | setSizeIncrement (const QSize &size) |
void | setSurfaceType (SurfaceType surfaceType) |
void | setTransientParent (QWindow *parent) |
void | setVulkanInstance (QVulkanInstance *instance) |
void | setWindowState (Qt::WindowState state) |
QSize | size () const override |
QSize | sizeIncrement () const |
SurfaceType | surfaceType () const override |
QWindow * | transientParent () const |
Qt::WindowType | type () const |
void | unsetCursor () |
QVulkanInstance * | vulkanInstance () const |
Qt::WindowState | windowState () const |
WId | winId () const |
![]() | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
![]() | |
virtual | ~QSurface () |
virtual QSurfaceFormat | format () const = 0 |
virtual QSize | size () const = 0 |
bool | supportsOpenGL () const |
SurfaceClass | surfaceClass () const |
virtual QPlatformSurface * | surfaceHandle () const = 0 |
virtual SurfaceType | surfaceType () const = 0 |
![]() | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Protected Methods | |
int | metric (PaintDeviceMetric metric) const override |
void | paintEvent (QPaintEvent *event) override |
![]() | |
int | metric (PaintDeviceMetric metric) const override |
![]() | |
bool | event (QEvent *event) override |
virtual void | exposeEvent (QExposeEvent *event) |
virtual void | focusInEvent (QFocusEvent *event) |
virtual void | focusOutEvent (QFocusEvent *event) |
virtual void | hideEvent (QHideEvent *event) |
virtual void | keyPressEvent (QKeyEvent *event) |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
virtual void | mousePressEvent (QMouseEvent *event) |
virtual void | mouseReleaseEvent (QMouseEvent *event) |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | resizeEvent (QResizeEvent *event) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
![]() | |
QSurface (SurfaceClass type) | |
![]() | |
QPaintDevice () | |
Additional Inherited Members | |
![]() | |
enum | AncestorMode |
enum | Visibility |
![]() | |
enum | SurfaceClass |
enum | SurfaceType |
![]() | |
enum | PaintDeviceMetric |
![]() | |
void | contentOrientationChanged (Qt::ScreenOrientation orientation) |
void | focusObjectChanged (QObject *object) |
void | modalityChanged (Qt::WindowModality modality) |
void | screenChanged (QScreen *screen) |
void | windowStateChanged (Qt::WindowState windowState) |
![]() | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
![]() | |
void | update () |
![]() | |
void | alert (int msec) |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | requestActivate () |
void | requestUpdate () |
void | setMaximumWidth (int width) |
void | setVisible (bool visible) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
![]() | |
void | deleteLater () |
![]() | |
static QWindow * | fromWinId (WId id) |
![]() | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
![]() | |
height | |
width | |
![]() | |
active | |
contentOrientation | |
flags | |
height | |
maximumHeight | |
maximumWidth | |
minimumHeight | |
minimumWidth | |
modality | |
opacity | |
title | |
visibility | |
visible | |
width | |
x | |
y | |
![]() | |
objectName | |
![]() | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QOpenGLWindow class is a convenience subclass of QWindow to perform OpenGL painting.
QOpenGLWindow is an enhanced QWindow that allows easily creating windows that perform OpenGL rendering using an API that is compatible with QOpenGLWidget and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow has no dependency on the widgets module and offers better performance.
A typical application will subclass QOpenGLWindow and reimplement the following virtual functions:
To schedule a repaint, call the update() function. Note that this will not immediately result in a call to paintGL(). Calling update() multiple times in a row will not change the behavior in any way.
This is a slot so it can be connected to a QTimer::timeout() signal to perform animation. Note however that in the modern OpenGL world it is a much better choice to rely on synchronization to the vertical refresh rate of the display. See setSwapInterval() on a description of the swap interval. With a swap interval of 1, which is the case on most systems by default, the swapBuffers() call, that is executed internally by QOpenGLWindow after each repaint, will block and wait for vsync. This means that whenever the swap is done, an update can be scheduled again by calling update(), without relying on timers.
To request a specific configuration for the context, use setFormat() like for any other QWindow. This allows, among others, requesting a given OpenGL version and profile, or enabling depth and stencil buffers.
Unlike QWindow, QOpenGLWindow allows opening a painter on itself and perform QPainter-based drawing.
QOpenGLWindow supports multiple update behaviors. The default, NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the legacy QGLWidget. In contrast, PartialUpdateBlit and PartialUpdateBlend are more in line with QOpenGLWidget's way of working, where there is always an extra, dedicated framebuffer object present. These modes allow, by sacrificing some performance, redrawing only a smaller area on each paint and having the rest of the content preserved from of the previous frame. This is useful for applications than render incrementally using QPainter, because this way they do not have to redraw the entire window content on each paintGL() call.
Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share with each other. This allows accessing each other's shareable OpenGL resources.
For more information on graphics refer to Graphics View.
QOpenGLWindow::~QOpenGLWindow | ( | ) |
Destroys the QOpenGLWindow instance, freeing its resources.
The OpenGLWindow's context is made current in the destructor, allowing for safe destruction of any child object that may need to release OpenGL resources belonging to the context provided by this window.
If you have objects wrapping OpenGL resources (such as QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a QOpenGLWindow subclass, you may need to add a call to makeCurrent() in that subclass' destructor as well. Due to the rules of C++ object destruction, those objects will be destroyed before calling this function (but after that the destructor of the subclass has run), therefore making the OpenGL context current in this function happens too late for their safe disposal.
|
overrideprotectedvirtual |
Returns the metric information for the given paint device metric.
Reimplemented from QPaintDevice::metric()
|
overrideprotectedvirtual |
Handles paint events passed by the parameter event. The default implementation does nothing. Reimplement this function to perform painting. If necessary, the dirty area is retrievable from the event.
Reimplemented from QPaintDeviceWindow::paintEvent()