Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_kernel_qevent.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QWheelEvent>
4
6class MyWidget //: public QWidget
7{
8 void wheelEvent(QWheelEvent *event);
9 void scrollWithPixels(QPoint point);
10 void scrollWithDegrees(QPoint point);
11};
12
13
14//! [0]
15void MyWidget::wheelEvent(QWheelEvent *event)
16{
17 QPoint numPixels = event->pixelDelta();
18 QPoint numDegrees = event->angleDelta() / 8;
19
20 if (!numPixels.isNull()) {
21 scrollWithPixels(numPixels);
22 } else if (!numDegrees.isNull()) {
23 QPoint numSteps = numDegrees / 15;
24 scrollWithDegrees(numSteps);
25 }
26
27 event->accept();
28}
29//! [0]
30
31
32} // src_gui_kernel_qevent