summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qwidget.cpp34
-rw-r--r--src/widgets/kernel/qwidget.h10
2 files changed, 43 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2cb259468d..70bc407587 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6387,6 +6387,24 @@ void QWidget::setWindowRole(const QString &role)
\sa mouseMoveEvent()
*/
+/*!
+ \property QWidget::tabletTracking
+ \brief whether tablet tracking is enabled for the widget
+ \since 5.9
+
+ If tablet tracking is disabled (the default), the widget only
+ receives tablet move events when the stylus is in contact with
+ the tablet, or at least one stylus button is pressed,
+ while the stylus is being moved.
+
+ If tablet tracking is enabled, the widget receives tablet move
+ events even while hovering in proximity. This is useful for
+ monitoring position as well as the auxiliary properties such
+ as rotation and tilt, and providing feedback in the UI.
+
+ \sa tabletEvent()
+*/
+
/*!
Sets the widget's focus proxy to widget \a w. If \a w is 0, the
@@ -8788,6 +8806,9 @@ bool QWidget::event(QEvent *event)
#endif
#ifndef QT_NO_TABLETEVENT
case QEvent::TabletMove:
+ if (static_cast<QTabletEvent *>(event)->buttons() == Qt::NoButton && !testAttribute(Qt::WA_TabletTracking))
+ break;
+ Q_FALLTHROUGH();
case QEvent::TabletPress:
case QEvent::TabletRelease:
tabletEvent((QTabletEvent*)event);
@@ -9020,6 +9041,7 @@ bool QWidget::event(QEvent *event)
case QEvent::IconTextChange:
case QEvent::ModifiedChange:
case QEvent::MouseTrackingChange:
+ case QEvent::TabletTrackingChange:
case QEvent::ParentChange:
case QEvent::LocaleChange:
case QEvent::MacSizeChange:
@@ -9425,7 +9447,13 @@ void QWidget::wheelEvent(QWheelEvent *event)
The default implementation ignores the event.
- \sa QEvent::ignore(), QEvent::accept(), event(),
+ If tablet tracking is switched off, tablet move events only occur if the
+ stylus is in contact with the tablet, or at least one stylus button is
+ pressed, while the stylus is being moved. If tablet tracking is switched on,
+ tablet move events occur even while the stylus is hovering in proximity of
+ the tablet, with no buttons pressed.
+
+ \sa QEvent::ignore(), QEvent::accept(), event(), setTabletTracking(),
QTabletEvent
*/
@@ -11194,6 +11222,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
QEvent e(QEvent::MouseTrackingChange);
QApplication::sendEvent(this, &e);
break; }
+ case Qt::WA_TabletTracking: {
+ QEvent e(QEvent::TabletTrackingChange);
+ QApplication::sendEvent(this, &e);
+ break; }
case Qt::WA_NativeWindow: {
d->createTLExtra();
if (on)
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 4c80038a4f..1c378924a0 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -161,6 +161,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
#endif
Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
+ Q_PROPERTY(bool tabletTracking READ hasTabletTracking WRITE setTabletTracking)
Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
Q_PROPERTY(bool focus READ hasFocus)
@@ -328,6 +329,9 @@ public:
bool hasMouseTracking() const;
bool underMouse() const;
+ void setTabletTracking(bool enable);
+ bool hasTabletTracking() const;
+
void setMask(const QBitmap &);
void setMask(const QRegion &);
QRegion mask() const;
@@ -809,6 +813,12 @@ inline bool QWidget::hasMouseTracking() const
inline bool QWidget::underMouse() const
{ return testAttribute(Qt::WA_UnderMouse); }
+inline void QWidget::setTabletTracking(bool enable)
+{ setAttribute(Qt::WA_TabletTracking, enable); }
+
+inline bool QWidget::hasTabletTracking() const
+{ return testAttribute(Qt::WA_TabletTracking); }
+
inline bool QWidget::updatesEnabled() const
{ return !testAttribute(Qt::WA_UpdatesDisabled); }