diff --git a/HX_CameraLoopPlay/CameraLoopPlay.cpp b/HX_CameraLoopPlay/CameraLoopPlay.cpp index 35d83c2..605c703 100644 --- a/HX_CameraLoopPlay/CameraLoopPlay.cpp +++ b/HX_CameraLoopPlay/CameraLoopPlay.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // 相机列表JSON文件名称 const QString CameraJsonFileName = "camera.json"; @@ -63,7 +64,37 @@ CameraLoopPlay::~CameraLoopPlay() bool CameraLoopPlay::eventFilter(QObject* watched, QEvent* event) { - return false; + // 处理鼠标按下、释放和移动事件 + if (watched == ui->widget_title) { + QMouseEvent* mouseEvent = static_cast(event); + if (mouseEvent->type() == QEvent::MouseButtonPress) { + if (mouseEvent->button() == Qt::LeftButton) { + m_mousePressed = true; // 启动拖拽 + m_mousePoint = mouseEvent->globalPos() - this->pos(); + + this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::Window | Qt::WindowStaysOnTopHint); + this->show(); // 确保窗口显示 + + return true; + } + } + else if (mouseEvent->type() == QEvent::MouseButtonRelease) { + m_mousePressed = false; + return true; + } + else if (mouseEvent->type() == QEvent::MouseMove) { + if (m_mousePressed && (mouseEvent->buttons() & Qt::LeftButton)) { + this->move(mouseEvent->globalPos() - m_mousePoint); + + // 每次移动时设置为最上方 + this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::Window | Qt::WindowStaysOnTopHint); + this->show(); + return true; + } + } + } + + return QWidget::eventFilter(watched, event); } void CameraLoopPlay::on_pushButton_min_clicked() diff --git a/HX_CameraLoopPlay/CameraLoopPlay.h b/HX_CameraLoopPlay/CameraLoopPlay.h index 7d02130..4735a86 100644 --- a/HX_CameraLoopPlay/CameraLoopPlay.h +++ b/HX_CameraLoopPlay/CameraLoopPlay.h @@ -211,6 +211,12 @@ private: */ QList m_singleCameraWidgetList; - + /** + * @brief ק + * @author XuChao (xxu715737@163.com) + * @date 2024-10-29 + */ + QPoint m_mousePoint; + bool m_mousePressed{ false }; }; diff --git a/HX_CameraLoopPlay/CameraLoopPlay.ui b/HX_CameraLoopPlay/CameraLoopPlay.ui index ad9881a..0665f51 100644 --- a/HX_CameraLoopPlay/CameraLoopPlay.ui +++ b/HX_CameraLoopPlay/CameraLoopPlay.ui @@ -294,6 +294,25 @@ QPushButton:hover{ + + + + + 20 + 20 + + + + #pushButton_refresh{ + border:0px; + border-image: url(:/CameraLoopPlay/Resource/image/refresh.png); +} + + + + + + diff --git a/HX_CameraLoopPlay/CameraThread.cpp b/HX_CameraLoopPlay/CameraThread.cpp index 8b60595..3c60d74 100644 --- a/HX_CameraLoopPlay/CameraThread.cpp +++ b/HX_CameraLoopPlay/CameraThread.cpp @@ -72,7 +72,7 @@ bool CameraThread::realPlay(HWND hWnd, int index) struPlayInfo.lChannel = 0 + iIpcStartChan[index]; //Ԥͨ struPlayInfo.dwStreamType = 1; //ͣ0-1-2-3-Դ - struPlayInfo.dwLinkMode = 4; //0- TCP ʽ1- UDP ʽ2- ಥʽ3- RTP ʽ4-RTP/RTSP5-RSTP/HTTP + struPlayInfo.dwLinkMode = 0; //0- TCP ʽ1- UDP ʽ2- ಥʽ3- RTP ʽ4-RTP/RTSP5-RSTP/HTTP struPlayInfo.bBlocked = 1; //0- ȡ1- ȡ iRealPlayHandle = NET_DVR_RealPlay_V40(loginId, &struPlayInfo, NULL, NULL); // ʵʱԤ