QwtWidgetOverlay - An overlay for a widget.
Contents
Constructor & Destructor Documentation
QwtWidgetOverlay::QwtWidgetOverlay(QWidget*widget)
Constructor.
Parameters:widget Parent widget, where the overlay is aligned to
Detailed Description
An overlay for a widget.
The main use case of an widget overlay is to avoid heavy repaint operation of the widget below.
F.e. in combination with the plot canvas an overlay avoid replots as the content of the canvas can be
restored from its backing store.
QwtWidgetOverlay is an abstract base class. Deriving classes are supposed to reimplement the following
methods:
• drawOverlay()
• maskHint()
Internally QwtPlotPicker uses overlays for displaying the rubber band and the tracker text.
Seealso:QwtPlotCanvas::BackingStoreMember Enumeration Documentation
enumQwtWidgetOverlay::MaskMode
Mask mode. When using masks the widget below gets paint events for the masked regions of the overlay
only. Otherwise Qt triggers full repaints. On less powerful hardware ( f.e embedded systems ) - or when
using the raster paint engine on a remote desktop - bit blitting is a noticeable operation, that needs to
be avoided.
If and how to mask depends on how expensive the calculation of the mask is and how many pixels can be
excluded by the mask.
The default setting is MaskHint.
Seealso:setMaskMode(), maskMode()EnumeratorNoMask Don't use a mask.
MaskHint
Use maskHint() as mask. For many situations a fast approximation is good enough and it is not
necessary to build a more detailed mask ( f.e the bounding rectangle of a text ).
AlphaMask
Calculate a mask by checking the alpha values. Sometimes it is not possible to give a fast
approximation and the mask needs to be calculated by drawing the overlay and testing the result.
When a valid maskHint() is available only pixels inside this approximation are checked.
enumQwtWidgetOverlay::RenderMode
Render mode. For calculating the alpha mask the overlay has already been painted to a temporary QImage.
Instead of rendering the overlay twice this buffer can be copied for drawing the overlay.
On graphic systems using the raster paint engine ( QWS, Windows ) it means usually copying some memory
only. On X11 it results in an expensive operation building a pixmap and for simple overlays it might not
be recommended.
Note:
The render mode has no effect, when maskMode() != AlphaMask.
EnumeratorAutoRenderMode
Copy the buffer, when using the raster paint engine.
CopyAlphaMask
Always copy the buffer.
DrawOverlay
Never copy the buffer.
Member Function Documentation
virtualvoidQwtWidgetOverlay::drawOverlay(QPainter*painter)const[protected],[purevirtual]
Draw the widget overlay
Parameters:painter Painter
boolQwtWidgetOverlay::eventFilter(QObject*object,QEvent*event)[virtual]
Event filter. Resize the overlay according to the size of the parent widget.
Parameters:object Object to be filtered
event Event
Returns:
See QObject::eventFilter()
QRegionQwtWidgetOverlay::maskHint()const[protected],[virtual]
Calculate an approximation for the mask.
• MaskHint The hint is used as mask.
• AlphaMask The hint is used to speed up the algorithm for calculating a mask from non transparent pixels
• NoMask The hint is unused.
The default implementation returns an invalid region indicating no hint.
Returns:
Hint for the mask
QwtWidgetOverlay::MaskModeQwtWidgetOverlay::maskMode()constReturns:
Mode how to find the mask for the overlay
Seealso:setMaskMode()voidQwtWidgetOverlay::paintEvent(QPaintEvent*event)[protected],[virtual]
Paint event
Parameters:event Paint event
Seealso:drawOverlay()QwtWidgetOverlay::RenderModeQwtWidgetOverlay::renderMode()constReturns:
Render mode
Seealso:RenderMode, setRenderMode()voidQwtWidgetOverlay::resizeEvent(QResizeEvent*event)[protected],[virtual]
Resize event
Parameters:event Resize event
voidQwtWidgetOverlay::setMaskMode(MaskModemode)
Specify how to find the mask for the overlay.
Parameters:mode New mode
Seealso:maskMode()voidQwtWidgetOverlay::setRenderMode(RenderModemode)
Set the render mode
Parameters:mode Render mode
Seealso:RenderMode, renderMode()voidQwtWidgetOverlay::updateOverlay()
Recalculate the mask and repaint the overlay
Name
QwtWidgetOverlay - An overlay for a widget.
Synopsis
#include <qwt_widget_overlay.h>
Inherits QWidget.
Inherited by QwtPickerRubberband, and QwtPickerTracker.
PublicTypes
enum MaskMode { NoMask, MaskHint, AlphaMask }
Mask mode.
enum RenderMode { AutoRenderMode, CopyAlphaMask, DrawOverlay }
Render mode.
PublicMemberFunctionsQwtWidgetOverlay (QWidget *)
Constructor.
virtual ~QwtWidgetOverlay ()
Destructor.
void setMaskMode (MaskMode)
Specify how to find the mask for the overlay.
MaskModemaskMode () const
void setRenderMode (RenderMode)
RenderModerenderMode () const
void updateOverlay ()
virtual bool eventFilter (QObject *, QEvent *)
Event filter.
ProtectedMemberFunctions
virtual void paintEvent (QPaintEvent *event)
virtual void resizeEvent (QResizeEvent *event)
virtual QRegion maskHint () const
Calculate an approximation for the mask.
virtual void drawOverlay (QPainter *painter) const =0
