NDEVR
API Documentation
WindowContainer

A (hacky) class for storing a window into a container. More...

Inheritance diagram for WindowContainer:
[legend]

Public Member Functions

 WindowContainer (QWidget *parent=nullptr)
 Constructs a WindowContainer with an optional parent.
bool event (QEvent *event) override
 Handles show/hide events and forwards all events to the optional event forwarder.
void paintEvent (QPaintEvent *event) override
 Handles paint events, updating the embedded window size on non-special-window platforms.
void setEventForwarder (const std::function< bool(QEvent *event)> &forwarder)
 Sets a callback function that receives all events for custom processing.
void setWidget (QWidget *window)
 Sets a QWidget as the contained child widget.
void setWindow (QWindow *window)
 Sets a QWindow as the contained window, wrapping it in a QWidget container.
virtual void updateSize ()
 Updates the geometry of the embedded container to match this widget's size and position.
void visibleHack ()
 Workaround to force proper visibility of the embedded window on some platforms.
QPoint windowOffset () const
 Returns the global position offset for the embedded window.

Static Public Member Functions

static Qt::WindowFlags windowFlags ()
 Returns the platform-specific window flags for the embedded window.

Protected Attributes

QWidget * m_container
 The QWidget wrapping the embedded window or set directly via setWidget().
std::function< bool(QEvent *event)> m_event_forwarder
 Optional callback that receives all events for custom handling.
QSize m_last_paint_size
 The size at the last paint event, used for incremental repainting.
QTimer * m_location_timer
 Timer used on some platforms to poll and update window position.
QWindow * m_window
 The embedded QWindow, if set via setWindow().

Detailed Description

A (hacky) class for storing a window into a container.


This is used if the rendering engine for a particular widget is different from the one used by the application. The hackiness comes from Qt's limited support for this functionality which results in the need to hack around the errors in Qt's core library.

Definition at line 36 of file WindowContainer.h.

Constructor & Destructor Documentation

◆ WindowContainer()

WindowContainer::WindowContainer ( QWidget * parent = nullptr)
inline

Constructs a WindowContainer with an optional parent.

Parameters
[in]parentThe optional parent widget.

Definition at line 41 of file WindowContainer.h.

References m_container, m_last_paint_size, m_location_timer, and m_window.

Member Function Documentation

◆ setEventForwarder()

void WindowContainer::setEventForwarder ( const std::function< bool(QEvent *event)> & forwarder)
inline

Sets a callback function that receives all events for custom processing.

Parameters
[in]forwarderThe event forwarding function.

Definition at line 251 of file WindowContainer.h.

References event(), and m_event_forwarder.

◆ setWidget()

void WindowContainer::setWidget ( QWidget * window)
inline

Sets a QWidget as the contained child widget.

Parameters
[in]windowThe widget to embed in this container.

Definition at line 94 of file WindowContainer.h.

References m_container, and m_window.

◆ setWindow()

void WindowContainer::setWindow ( QWindow * window)
inline

Sets a QWindow as the contained window, wrapping it in a QWidget container.

Parameters
[in]windowThe QWindow to embed in this container.

Definition at line 122 of file WindowContainer.h.

References m_container, m_window, and windowFlags().

◆ windowFlags()

Qt::WindowFlags WindowContainer::windowFlags ( )
inlinestatic

Returns the platform-specific window flags for the embedded window.

Returns
The Qt::WindowFlags to use.

Definition at line 67 of file WindowContainer.h.

Referenced by GLESCameraViewFactory::createView(), and setWindow().

◆ windowOffset()

QPoint WindowContainer::windowOffset ( ) const
inline

Returns the global position offset for the embedded window.

Returns
The offset as a QPoint.

Definition at line 84 of file WindowContainer.h.

Referenced by updateSize().


The documentation for this class was generated from the following file: