1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/test/testbodymover/qqtbodymover.h
tianduanrui 61f1dae97b add qqtbodymover.
press on window body and move window.
support: windows \ unix \ linux \ e-linux
2019-08-25 11:14:05 +08:00

45 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef QQTBODYMOVER_H
#define QQTBODYMOVER_H
#include <QObject>
//#include "qqt-local.h"
#define QQTSHARED_EXPORT
/**
* @brief The QQtBodyMover class
* 摁住窗体就能移动窗口。
*
* 使用方法:
* QWidget* w;//需要锁定鼠标的窗口。
* w->setMouseTracking(True);//不必要
* //w->setFocusPolicy(Qt::StrongFocus);//不必要设置Focus。
* QQtBodyMover* helper = new QQtBodyMover(parent) ;
* w->installEventFilter(helper);//一步设置即可。
* 允许使用这一个句柄为多个窗口安装,各自独立工作,互不干扰。
*
* 工作原理:
* 在鼠标move的时候截获鼠标消息使窗口移动。
* 支持所有QWidget及其子类不支持QMainWindow。
* 支持windows、macOS、Linux等桌面操作系统。
*/
class QQtBodyMoverPrivate;
class QQTSHARED_EXPORT QQtBodyMover : public QObject
{
Q_OBJECT
public:
QQtBodyMover ( QObject* parent = 0 );
~QQtBodyMover();
// QObject interface
public:
virtual bool eventFilter ( QObject* watched, QEvent* event ) override;
private:
QQtBodyMoverPrivate* d_ptr;
Q_DECLARE_PRIVATE ( QQtBodyMover )
};
#endif // QQTBODYMOVER_H