Blame view

LiveChat/FeiTalk/gui/ivideoitemteach.cpp 1.31 KB
9f17d59e   陈明泉   no message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  #include "ivideoitemteach.h"
  #include <QMouseEvent>
  #include <QApplication>
  #include <QDesktopWidget>
  #include <QLabel>
  #include <QDebug>
  
  
  IVideoItemTeach::IVideoItemTeach(QWidget *parent) :
      QWidget(parent)
  {
      QLabel *label =new QLabel(this);
      label->setGeometry(0, 0, 240, 320);
      label->setPixmap(QPixmap(":Images/VideoCall/teacher_default.png"));
      label->show();
  
  }
  void IVideoItemTeach::mousePressEvent(QMouseEvent *event)
  {
      if (event->button() == Qt::LeftButton) {
          dragPosition = event->globalPos() - frameGeometry().topLeft();
          event->accept();
      }
  }
  
  void IVideoItemTeach::mouseReleaseEvent(QMouseEvent *)
  {
      if (geometry().y() < QApplication::desktop()->geometry().top()) {
          move(geometry().x(), QApplication::desktop()->geometry().top());
      }
  }
  
  void IVideoItemTeach::mouseMoveEvent(QMouseEvent *event)
  {
  
  
      if(event->globalPos().x() - dragPosition.x() < 0)
      {
  
          this->move(0, QPoint(event->globalPos() - dragPosition).y());
          event->ignore();
          return;
      }
  
      if(event->globalPos().y() - dragPosition.y() < 0)
      {
          this->move(QPoint(event->globalPos() - dragPosition).x(),0);
          event->ignore();
          return;
      }
      if (event->buttons() &Qt::LeftButton) {
          move(event->globalPos() - dragPosition);
          event->accept();
      }
  }