DragAbleDialog.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * 叶海辉
  3. * QQ群121376426
  4. * http://blog.yundiantech.com/
  5. */
  6. #ifndef DRAGABLEDIALOG_H
  7. #define DRAGABLEDIALOG_H
  8. #include <QWidget>
  9. #include <QTimer>
  10. #include <QDialog>
  11. namespace Ui {
  12. class DragAbleDialog;
  13. }
  14. class DragAbleDialog : public QDialog
  15. {
  16. Q_OBJECT
  17. public:
  18. explicit DragAbleDialog(QWidget *parent = 0);
  19. ~DragAbleDialog();
  20. QWidget *getContainWidget();
  21. void setTitle(QString str);
  22. void doShowMaxSize();
  23. void doShowFullScreen();
  24. void doShowNormal();
  25. private:
  26. Ui::DragAbleDialog *ui;
  27. QTimer *mTimer;
  28. ///以下是改变窗体大小相关
  29. ////////
  30. protected:
  31. void mouseReleaseEvent(QMouseEvent *event);
  32. void mouseMoveEvent(QMouseEvent *event);
  33. void mousePressEvent(QMouseEvent *event);
  34. private:
  35. bool isMax; //是否最大化
  36. QRect mLocation;
  37. bool mIsResizeMode;
  38. bool isLeftPressDown; // 判断左键是否按下
  39. QPoint dragPosition; // 窗口移动拖动时需要记住的点
  40. int dir; // 窗口大小改变时,记录改变方向
  41. void checkCursorDirect(const QPoint &cursorGlobalPoint);
  42. void showBorderRadius(bool isShow);
  43. void doChangeFullScreen();
  44. void doChangeMaxSize();
  45. private slots:
  46. void slotTimerTimeOut();
  47. };
  48. #endif // DRAGABLEDIALOG_H