Compare commits

...

1 Commits

Author SHA1 Message Date
徐超 5175156b46 feat:视频轮询 2024-12-12 10:25:39 +08:00
4 changed files with 59 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QMouseEvent>
// 相机列表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<QMouseEvent*>(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()

View File

@ -211,6 +211,12 @@ private:
*/
QList<Ui::SingleCameraWidget*> m_singleCameraWidgetList;
/**
* @brief ´°¿ÚÍÏ×§
* @author XuChao (xxu715737@163.com)
* @date 2024-10-29
*/
QPoint m_mousePoint;
bool m_mousePressed{ false };
};

View File

@ -294,6 +294,25 @@ QPushButton:hover{
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_refresh">
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">#pushButton_refresh{
border:0px;
border-image: url(:/CameraLoopPlay/Resource/image/refresh.png);
}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -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); // 实时预览