fix :修改滚轮变倍功能

Video_Medical
wanghaoyu 4 days ago
parent e2bf903a68
commit 2fc16d1383

@ -473,6 +473,26 @@ void CommandWidget::on_cmdLineEdit_textChanged(const QString text)
ui->cmdSlider->setMaximum(text.toInt());
}
void CommandWidget::wheelZoomCtrl(int value)
{
if (value > 0)//鼠标前滚
{
void on_pushButton_zoomp_pressed();
qDebug() << "滚轮变倍+" << value;
}
else if (value < 0)
{
void on_pushButton_zoomd_pressed();
qDebug() << "滚轮变倍-" << value;
}
else if (value == 0)
{
void on_pushButton_zoomp_released();
qDebug() << "停止变倍:" << value;
}
}
void CommandWidget::setPodIPConfig(NetworkIPStruct networkIP, bool isConnect)
{
qDebug() << "ip设置槽函数调用了";

@ -216,6 +216,7 @@ private slots:
void on_cmdLineEdit_textChanged(const QString text);
private:
Ui::CommandWidget *ui;
QUdpSocket *m_commandUdpSocket = nullptr;
@ -247,6 +248,8 @@ public:
void setTargetTracking(double dir, double pitch);
//停止跟踪
void setStopTracking();
//滚轮控制变倍
void wheelZoomCtrl(int value);
};
#endif // COMMANDWIDGET_H

@ -127,6 +127,7 @@ void MainWindow::initSignalConnection() {
&MainWindow::closeVideoSlot);
connect(&streamAddrSettingsDlg, &StreamAddrSettingsDlg::sendUavTypeIndex, ui->commandWidget, &CommandWidget::receiveUavTypeIndex);
}
void MainWindow::initNotifyMessageConnection() {
@ -539,6 +540,11 @@ void MainWindow::initPodParam()
lastLocation->hide();
connect(&settingDlg, &CommunicationSettingDlg::sendPodData, ui->commandWidget, &CommandWidget::setPodIPConfig);
connect(_wheelStopTime, &QTimer::timeout, this, [this]() {
ui->commandWidget->wheelZoomCtrl(0);
qDebug() << "滚轮停止了";
});
}
void MainWindow::mousePressEvent(QMouseEvent* event)
@ -623,3 +629,50 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* event)
}
}
}
void MainWindow::wheelEvent(QWheelEvent* event)
{
if (ui->videoWidget->underMouse())
{
// 获取滚轮的滚动方向和角度增量
_delta = event->angleDelta().y();
QPointF currentLocation = event->position();
// qDebug() << "当前位置:" << currentLocation;
if (_delta > 0)
{
// 向上滚动
qDebug() << "鼠标滚轮向上滚动" << " 步长:" << _delta;
// if(wheelSub->isVisible())
// {
// wheelSub->hide();
// }
// wheelPlus->move((currentLocation - QPoint(wheelPlus->width()/2, wheelPlus->height()/2)).toPoint());
// wheelPlus->show();
ui->commandWidget->wheelZoomCtrl(_delta);
}
else if (_delta < 0)
{
// 向下滚动
// if(wheelPlus->isVisible())
// {
// wheelPlus->hide();
// }
// wheelSub->move((currentLocation - QPoint(wheelSub->width()/2, wheelSub->height()/2)).toPoint());
// wheelSub->show();
ui->commandWidget->wheelZoomCtrl(_delta);
qDebug() << "鼠标滚轮事向下滚动" << " 步长:" << _delta;
}
if (!_wheelStopTime->isActive())
{
_wheelStopTime->start();
}
else
{
_wheelStopTime->stop();
_wheelStopTime->start();
}
}
QWidget::wheelEvent(event);
}

@ -55,6 +55,7 @@ protected:
signals:
void themeChanged();
void sendErrorMessage(QString message, int type);
void wheelSendData(int value);
private:
void initSignalConnection();
@ -110,5 +111,7 @@ public:
void mouseMoveEvent(QMouseEvent* event) override; // 事件过滤器
void mouseReleaseEvent(QMouseEvent* event) override;
protected:
void wheelEvent(QWheelEvent* event) override;
};
#endif // MAINWINDOW_H

Loading…
Cancel
Save