diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-15 16:30:25 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-16 13:37:38 +0200 |
commit | 8e94af2ed0577936cabaffab336014c1be9002af (patch) | |
tree | e058a5431475f91d07fcaeab3344d39508b1210d /src/widgets | |
parent | 322387ce7b5e768d6bd0b8dda1b8f9b704e88f47 (diff) |
Revamp the shapedclock example
Rename it to "Translucent Background", as that's what the example shows
how to do. And modern applications shouldn't use a (binary) mask to
create shaped windows. Instead, set the TranslucentBackground attribute,
don't paint pixels that should be fully transparent and use anti-aliased
or semi-opaque painting for pixels that should be translucent.
Adjust the example and documentation accordingly. Move the statment that
widget masks create coarse visual clipping to the QWidget::setMask
documentation.
Pick-to: 6.5
Change-Id: Id49d854093f2cb471afb178d32723081c7543543
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index d0ad169024..1b8e9890b5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -10233,7 +10233,7 @@ void QWidget::ensurePolished() const Returns the mask currently set on a widget. If no mask is set the return value will be an empty region. - \sa setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example} + \sa setMask(), clearMask(), QRegion::isEmpty() */ QRegion QWidget::mask() const { @@ -12964,8 +12964,16 @@ QPainter *QWidget::sharedPainter() const widget, window system controls in that area may or may not be visible, depending on the platform. - Note that this effect can be slow if the region is particularly - complex. + Since QRegion allows arbitrarily complex regions to be created, widget + masks can be made to suit the most unconventionally-shaped windows, and + even allow widgets to be displayed with holes in them. Note that this + effect can be slow if the region is particularly complex. + + Widget masks are used to hint to the window system that the application + does not want mouse events for areas outside the mask. On most systems, + they also result in coarse visual clipping. To get smooth window edges, use + translucent background and anti-aliased painting instead, as shown in the + \l{Translucent Background} example. \sa windowOpacity */ @@ -13051,7 +13059,7 @@ void QWidgetPrivate::setMask_sys(const QRegion ®ion) Masked widgets receive mouse events only on their visible portions. - \sa clearMask(), windowOpacity(), {Shaped Clock Example} + \sa clearMask(), windowOpacity() */ void QWidget::setMask(const QBitmap &bitmap) { |