QGesture 類錶示包含描述相應用戶輸入特性的手勢。 更多...
| 頭: | #include <QGesture> |
| qmake: | QT += widgets |
| Since: | Qt 4.6 |
| 繼承: | QObject |
| 繼承者: |
QPanGesture , QPinchGesture , QSwipeGesture , QTapAndHoldGesture ,和 QTapGesture |
該類在 Qt 4.6 引入。
| enum | GestureCancelPolicy { CancelNone, CancelAllInContext } |
|
| QGesture (QObject * parent = nullptr) | |
| virtual | ~QGesture () |
| QGesture::GestureCancelPolicy | gestureCancelPolicy () const |
| Qt::GestureType | gestureType () const |
| bool | hasHotSpot () const |
| QPointF | hotSpot () const |
| void | setGestureCancelPolicy (QGesture::GestureCancelPolicy policy ) |
| void | setHotSpot (const QPointF & value ) |
| Qt::GestureState | state () const |
| void | unsetHotSpot () |
手勢對象不是由開發者直接構造的。它們的創建是通過 QGestureRecognizer 對象由應用程序注冊;見 QGestureRecognizer::registerRecognizer ().
Qt 中手勢處理的概述和在應用程序中使用手勢的有關信息,見 Widget 和圖形視圖中的手勢 文檔。
擁有用戶可查詢特性列錶的類,能獲得一些特定手勢自變量。例如,捏閤手勢擁有作為特性暴露的比例縮放因子。
Developers of custom gesture recognizers can add additional properties in order to provide additional information about a gesture. This can be done by adding new dynamic properties to a QGesture object, or by subclassing the QGesture class (or one of its subclasses).
A QGesture instance is implicitly created when needed and is owned by Qt. Developers should never destroy them or store them for later use as Qt may destroy particular instances of them and create new ones to replace them.
注冊手勢識彆器監視目標對象的輸入事件憑藉其 recognize() 函數,按要求更新手勢對象特性。
可以將手勢對象交付給目標對象在 QGestureEvent 若相應手勢是活動的 (或剛被取消)。交付的每個事件都含有手勢對象列錶,因為目標對象可以啓用支持一個以上手勢。由於 Qt 處理事件的方式,手勢事件可以被其它對象過濾掉。
另請參閱 QGestureEvent and QGestureRecognizer .
此枚舉描述如何接受可以自動取消其它手勢的手勢。
| 常量 | 值 | 描述 |
|---|---|---|
QGesture::CancelNone
|
0
|
接受此手勢時,其它手勢不受影響。 |
QGesture::CancelAllInContext
|
1
|
接受此手勢時,上下文中的所有活動手勢 (考慮 Qt::GestureFlag 的指定,當訂閱手勢時) 將被取消。 |
此特性保持決定接受手勢時會發生什麼的策略
當接受一個手勢時,Qt 可以自動取消屬於其它目標的其它手勢。策略通常設為不取消任何其它手勢,且可以被設為取消上下文中的所有活動手勢。例如,對於所有子級 Widget。
訪問函數:
| QGesture::GestureCancelPolicy | gestureCancelPolicy () const |
| void | setGestureCancelPolicy (QGesture::GestureCancelPolicy policy ) |
此特性保持手勢的類型
訪問函數:
| Qt::GestureType | gestureType () const |
此特性保持手勢是否擁有熱點
訪問函數:
| bool | hasHotSpot () const |
此特性保持用於查找手勢事件接收器的點。
熱點是全局坐標係中的點,使用 QWidget::mapFromGlobal () 或 QGestureEvent::mapToGraphicsScene () 獲取局部熱點。
應通過手勢識彆器設置熱點,以允許將手勢事件交付給 QGraphicsObject .
訪問函數:
| QPointF | hotSpot () const |
| void | setHotSpot (const QPointF & value ) |
| void | unsetHotSpot () |
此特性保持手勢的當前狀態
訪問函數:
| Qt::GestureState | state () const |
構造新的手勢對象采用給定 parent .
QGesture 對象是由手勢識彆器創建的在 QGestureRecognizer::create () 函數。
[虛擬]
QGesture::
~QGesture
()
銷毀手勢對象。