1、mousePressEvent事件
头文件中声明 bool isLeftPressDown;
QPoint m_movePoint;
并且初始化为 isLeftPressDown = false;
void MusicWidget::mousePressEvent(QMouseEvent *event)
{
switch(event->button())
{
case Qt::LeftButton:
isLeftPressDown = true;
m_movePoint = event->globalPos() - this->frameGeometry().topLeft();
//globalPos()鼠标全局位置,topLeft()窗口左上角的位置
}
break;
case Qt::RightButton:
this->setWindowState(Qt::WindowMinimized