30 #include <QApplication>
34 #include <QDialogButtonBox>
36 #include <QMainWindow>
39 #include <QMouseEvent>
41 #include <QPainterPath>
42 #include <QPlainTextEdit>
43 #include <QPointingDevice>
45 #include <QPushButton>
47 #include <QTabletEvent>
48 #include <QVBoxLayout>
51 # include <QtGui/private/qguiapplication_p.h>
52 # include <QtGui/qpa/qplatformintegration.h>
64 static void setWinTabEnabled(
bool e)
67 nativeWindowsApp->setWinTabEnabled(
e);
70 static bool isWinTabEnabled()
105 static bool m_tabletPenProximity;
110 switch (
event->type()) {
123 bool ProximityEventFilter::m_tabletPenProximity =
false;
153 bool m_lastIsMouseMove =
false;
154 bool m_lastIsTabletMove =
false;
159 int m_tabletMoveCount = 0;
160 int m_paintEventCount = 0;
173 int halfLineSpacing = lineSpacing / 2;
179 ellipse.addEllipse(0, 0, halfLineSpacing * 5, halfLineSpacing);
183 pp.
addEllipse(
t.pos, halfLineSpacing, halfLineSpacing);
184 QRectF pointBounds(
t.pos.x() - halfLineSpacing,
t.pos.y() - halfLineSpacing, lineSpacing, lineSpacing);
197 if (
t.pressure > 0.0) {
199 if (
t.angle != 0.0) {
202 p.scale(
t.pressure,
t.pressure);
207 p.drawEllipse(
t.pos,
t.pressure * halfLineSpacing,
t.pressure * halfLineSpacing);
211 p.fillRect(
t.pos.x() - 2,
t.pos.y() - 2, 4, 4,
Qt::black);
226 p.drawLine(
t.x() - 40,
t.y(),
t.x() + 40,
t.y());
227 p.drawLine(
t.x(),
t.y() - 40,
t.x(),
t.y() + 40);
234 QWidget::tabletEvent(
event);
236 m_tabletPos =
event->position();
237 switch (
event->type()) {
246 m_lastButton =
event->button();
258 if (!(isMove && m_lastIsTabletMove)) {
260 d <<
event <<
" global position = " <<
event->globalPosition()
263 d <<
" changed button " <<
event->button();
265 m_lastIsTabletMove = isMove;
270 switch (
event->type()) {
274 m_touchPoints.
clear();
276 m_touchPoints.
append(
p.position());
280 m_touchPoints.
clear();
292 if (m_lastIsMouseMove)
294 m_lastIsMouseMove =
true;
302 m_tabletMoveCount = 0;
303 m_paintEventCount = 0;
375 auto winTabAction = settingsMenu->addAction(
"WinTab");
378 winTabAction->setChecked(isWinTabEnabled());
381 winTabAction->setEnabled(
false);
389 if (m_devicesDialog.
isNull()) {
392 m_devicesDialog->
resize(500, 300);
396 m_devicesDialog->
show();
397 m_devicesDialog->
raise();
401 int main(
int argc,
char *argv[])
DevicesDialog(QWidget *p)
static bool tabletPenProximity()
ProximityEventFilter(QObject *parent)
bool eventFilter(QObject *, QEvent *event) override
The QAction class provides an abstraction for user commands that can be added to different user inter...
The QApplication class manages the GUI application's control flow and main settings.
The QDebug class provides an output stream for debugging information.
The QDialog class is the base class of dialog windows.
void setModal(bool modal)
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QEventPoint class provides information about a point in a QPointerEvent.
static QPlatformIntegration * platformIntegration()
void addWidget(QWidget *w)
void push_back(parameter_type t)
void append(parameter_type t)
The QMainWindow class provides a main application window.\inmodule QtWidgets.
void setCentralWidget(QWidget *widget)
The QMouseEvent class contains parameters that describe a mouse event.
The QObject class is the base class of all Qt objects.
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
void installEventFilter(QObject *filterObj)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
virtual bool event(QEvent *event)
The QPaintEvent class contains event parameters for paint events. \inmodule QtGui.
The QPainter class performs low-level painting on widgets and other paint devices.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void addEllipse(const QRectF &rect)
The QPlainTextEdit class provides a widget that is used to edit and display plain text.
void setPlainText(const QString &text)
void setReadOnly(bool ro)
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
The QPoint class defines a point in the plane using integer precision.
A base class for pointer events.
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr qreal height() const noexcept
constexpr qreal width() const noexcept
bool contains(const QRectF &r) const noexcept
constexpr QPointF topLeft() const noexcept
constexpr QPointF bottomRight() const noexcept
void showMessage(const QString &text, int timeout=0)
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
static QString number(int, int base=10)
The QTimerEvent class contains parameters that describe a timer event.
The QVBoxLayout class lines up widgets vertically.
bool isWinTabEnabled() const override
int main(int argc, char **argv)
MyMainWidget * mainWindow
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLboolean GLboolean GLboolean b
GLfixed GLfixed GLint GLint GLfixed points
QGraphicsEllipseItem * ellipse
QApplication app(argc, argv)
[0]
TabletPoint(const QPointF &p=QPointF(), TabletPointType t=TabletMove, Qt::MouseButton b=Qt::LeftButton, QPointingDevice::PointerType pt=QPointingDevice::PointerType::Unknown, qreal prs=0, qreal rotation=0)
QPointingDevice::PointerType ptype