Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.15.13
Description
User has a need to be able to transition between no mask (QT draws all of the widget) and full/blank mask (QT doesn’t draw any of the widget):
"
Our use case requires masking a variable portion of a QWidget - ranging from full widget rect() (QT paints entire widget) - to nothing (QT paint none of the widget).
`setMask(rect())` - means QT paint whole widget.
`setMask(QRect(0,0,0,0)) - means QT paints 1 pixel of the widget.
`setMask(QRegion{}) - means QT paint whole widget.
`clearMask()` - means QT paints whole widget.
How are we supposed to use setMask to mask out entire widget?
Why is `setMask(QRegion{})` treated same as `clearMask()`? This seems like a bug. There is a difference between "NO mask" and a "BLANK mask"
After all - you can call `setMask(QBitmap)` with all black pixels to achieve "BLANK mask" - why not via QRegion API?
Additional note: regarding the QT documentation:
QRegion QWidget::mask() const
Returns the mask currently set on a widget. If no mask is set the return value will be an empty region.
IMO this needed to be optional<QRegion> QWidget::mask() const
My idea for feature request – would be:
- Improve/extend QWidget::setMask() API, to be able to fully mask {}out{} the widget, so QT draws none of it…
- Possible via setMask(QBitmap) with all pixels `0` - but not possible via setMask(QRegion)
- Could be as simple as adding `QWidget::setBlankMask()`
- Or `QWidget::setMaskOut(QRegion)` for define region to mask out (vs mask in).
- or even differentiate between QRegion::isEmpty() vs QRegion::isNull()
"