#ifndef CURSORCONTROLLER_H #define CURSORCONTROLLER_H #include #include #include class CursorController : public QObject { Q_OBJECT public: explicit CursorController(QObject *parent = nullptr); // 可调参数 struct Config { int step = 20; // 每步像素 bool wrap = false;// 边缘回绕 bool emulate = true; // 是否发送点击事件 int edgeGap = 5; // 离边缘空隙 }; Config cfg; // 直接改成员即可实时生效 public slots: void handleKey(int key); // 接受 Qt::Key_xxx signals: void cursorMoved(const QPoint &globalPos); void clicked(QWidget *target); private: QPoint m_pos; bool m_useRealCursor; // true: 系统光标 false: 自绘光标 void move(const QPoint &delta); void emulateClick(); }; #endif // CURSORCONTROLLER_H