1#ifndef SARIBBONQT5COMPAT_HPP
2#define SARIBBONQT5COMPAT_HPP
3#include <QtCore/QtGlobal>
4#include <QtCore/QObject>
5#include <QtGui/QMouseEvent>
6#include <QtGui/QKeyEvent>
7#include <QtGui/QWheelEvent>
8#include <QtGui/QFontMetrics>
9#include <QtGui/QFontMetricsF>
27template<
typename EventType >
30#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
31 return event->globalPos();
33 return event->globalPosition().toPoint();
43template<
typename EventType >
46#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
49 return event->position().toPoint();
59template<
typename EventType >
62#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
63 return event->pos().x();
65 return static_cast< int >(
event->position().x());
75template<
typename EventType >
78#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
79 return event->pos().y();
81 return static_cast< int >(
event->position().y());
91template<
typename strType >
94#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
97 return fm.horizontalAdvance(str);
107template<
typename strType >
110#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
111 return fm.width(str);
113 return fm.horizontalAdvance(str);
136#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
139 return e->angleDelta().y();
int eventPosX(EventType *event)
获取事件的x坐标
Definition SARibbonQt5Compat.hpp:60
int horizontalAdvance(const QFontMetrics &fm, const strType &str)
计算字符串的水平宽度(整数版本)
Definition SARibbonQt5Compat.hpp:92
int wheelEventDelta(QWheelEvent *e)
Get vertical wheel delta value compatible with Qt5 and Qt6
Definition SARibbonQt5Compat.hpp:134
QPoint eventPos(EventType *event)
获取事件的位置(QPoint)
Definition SARibbonQt5Compat.hpp:44
QPoint eventGlobalPos(EventType *event)
获取事件的位置(QPoint)
Definition SARibbonQt5Compat.hpp:28
int eventPosY(EventType *event)
获取事件的y坐标
Definition SARibbonQt5Compat.hpp:76
qreal horizontalAdvanceF(const QFontMetricsF &fm, const strType &str)
计算字符串的水平宽度(浮点数版本)
Definition SARibbonQt5Compat.hpp:108