The QWheelEvent 類包含滾輪事件的描述參數。 更多...
| 頭: | #include <QWheelEvent> |
| 繼承: | QInputEvent |
| QWheelEvent (const QPoint & pos , int delta , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , Qt::Orientation orient = Qt::Vertical) | |
| QWheelEvent (const QPoint & pos , const QPoint & globalPos , int delta , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , Qt::Orientation orient = Qt::Vertical) | |
| Qt::MouseButtons | buttons () const |
| int | delta () const |
| const QPoint & | globalPos () const |
| int | globalX () const |
| int | globalY () const |
| Qt::Orientation | orientation () const |
| const QPoint & | pos () const |
| int | x () const |
| int | y () const |
The QWheelEvent 類包含滾輪事件的描述參數。
Wheel events are sent to the widget under the mouse cursor, but if that widget does not handle the event they are sent to the focus widget. The rotation distance is provided by delta ()。函數 pos () 和 globalPos () 返迴事件齣現時鼠標光標位置。
滾輪事件包含指示接收者是否想要事件的,特殊接受標誌。應該調用 ignore () 若不處理滾輪事件;這確保它會被發送給父級 Widget。
The QWidget::setEnabled () 函數可用於啓用 (或禁用) 小部件的鼠標事件和鍵盤事件。
事件處理程序 QWidget::wheelEvent () 接收滾輪事件。
另請參閱 QMouseEvent and QWidget::grabMouse ().
構造滾輪事件對象。
The position, pos , is the location of the mouse cursor within the widget. The globalPos () 被初始化為 QCursor::pos () which is usually, but not always, correct. Use the other constructor if you need to specify the global position explicitly.
The buttons describe the state of the mouse buttons at the time of the event, delta contains the rotation distance, modifiers holds the keyboard modifier flags at the time of the event, and orient holds the wheel's orientation.
另請參閱 pos (), delta (),和 state ().
構造滾輪事件對象。
The pos provides the location of the mouse cursor within the widget. The position in global coordinates is specified by globalPos . delta contains the rotation distance, modifiers holds the keyboard modifier flags at the time of the event, and orient holds the wheel's orientation.
另請參閱 pos (), globalPos (), delta (),和 state ().
返迴事件齣現時的鼠標狀態。
返迴鏇轉滾輪的距離,以八分之一度為單位。正值指示滾輪嚮前鏇轉遠離用戶;負值指示滾輪嚮後鏇轉朝著用戶。
大多數鼠標類型以 15 度步幅為單位工作,在這種情況下,增量值是 120 的倍增 (即:120 單位 *1/8 = 15 度)。
不管怎樣,一些鼠標擁有更精細分辨率的滾輪,並發送小於 120 單位 (小於 15 度) 的增量值。要支持這種可能性,可以纍加來自事件的增量值,直到達到 120,然後捲動 Widget,或者,可以部分捲動小部件以響應各滾輪事件。
範例:
void MyWidget::wheelEvent(QWheelEvent *event) { int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; if (event->orientation() == Qt::Horizontal) { scrollHorizontally(numSteps); } else { scrollVertically(numSteps); } event->accept(); }
返迴鼠標指針的全局位置 當事件發生時 。這對異步窗口係統 (譬如 X11) 很重要。每當圍繞響應鼠標事件移動 Widget 時,globalPos() 會非常不同於當前光標位置返迴通過 QCursor::pos ().
返迴事件發生時的鼠標光標全局 X 位置。
另請參閱 globalY () 和 globalPos ().
返迴事件發生時的鼠標光標全局 Y 位置。
另請參閱 globalX () 和 globalPos ().
Returns the wheel's orientation.
返迴相對於接收事件 Widget 的鼠標光標位置。
若圍繞響應鼠標事件移動 Widget,使用 globalPos () 而不是此函數。
另請參閱 x (), y (),和 globalPos ().
返迴相對於接收事件 Widget 的鼠標光標 X 位置。
返迴相對於接收事件 Widget 的鼠標光標 Y 位置。