1. 增加猫眼镜头切换IRCUT; 2. 优化连续多次打开视频获取视频流导致的内存问题
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
class NewButtonDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NewButtonDialog(QWidget* parent = nullptr, const QSize& labelSize = QSize(480, 640)) : QDialog(parent)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
QLabel* label = new QLabel("This is a new window opened by clicking the new button.", this);
|
||||
label->setFixedSize(labelSize); // 设置QLabel的固定大小
|
||||
layout->addWidget(label);
|
||||
|
||||
QPushButton* closeButton = new QPushButton("Close", this);
|
||||
layout->addWidget(closeButton);
|
||||
connect(closeButton, &QPushButton::clicked, this, &NewButtonDialog::accept);
|
||||
|
||||
setLayout(layout);
|
||||
setWindowTitle("SL100 视频播放窗口");
|
||||
//resize(500, 700); // 设置对话框的大小
|
||||
}
|
||||
};
|
||||
@@ -1,10 +1,11 @@
|
||||
// MainWidget.cpp
|
||||
#include "MainWidget.h"
|
||||
|
||||
void onThreadFinished(QThread* thread, ClientHandler* handler)
|
||||
void onThreadFinished(QThread* thread, ClientHandler* handler, DataHandler* dataHandler)
|
||||
{
|
||||
qDebug() << "Thread finished. Deleting handler and thread.";
|
||||
handler->deleteLater();
|
||||
dataHandler->deleteLater();
|
||||
thread->deleteLater();
|
||||
}
|
||||
|
||||
@@ -34,44 +35,11 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
licenseHwInfoEdit = new QTextEdit(this);
|
||||
UuidHwInfoEdit = new QTextEdit(this);
|
||||
|
||||
|
||||
|
||||
// 创建 mDNS 服务的 Server 和 Hostname 对象
|
||||
QMdnsEngine::Server myserver;
|
||||
QMdnsEngine::Hostname hostname(&myserver);
|
||||
|
||||
// 创建服务提供者(Provider)
|
||||
QMdnsEngine::Provider provider(&myserver, &hostname);
|
||||
|
||||
// 定义要广播的服务
|
||||
QMdnsEngine::Service service;
|
||||
service.setName("Test Service");
|
||||
service.setType("_test._tcp"); // 服务类型,包括 _tcp 或 _udp
|
||||
service.setPort(12345); // 服务使用的端口号
|
||||
|
||||
// 启动服务广播
|
||||
provider.update(service);
|
||||
|
||||
qDebug() << "mDNS service started. Broadcasting service:"
|
||||
<< service.name() << service.type() << "on port" << service.port();
|
||||
|
||||
|
||||
|
||||
setupUI();
|
||||
// 打印线程池状态信息
|
||||
setupTimerForThreadPoolInfo();
|
||||
server = new QTcpServer(this);
|
||||
/*
|
||||
// 创建 DataHandler 对象并连接信号
|
||||
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, licenseHwInfoEdit, &devInfoLineEdits,
|
||||
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||
frontBoardDevInfoJson, frontBoardLicenseJson,
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, this);
|
||||
|
||||
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
|
||||
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
||||
*/
|
||||
|
||||
connect(server, &QTcpServer::newConnection, this, [this]() {
|
||||
// 检查是否有挂起的连接
|
||||
while (server->hasPendingConnections()) {
|
||||
@@ -124,13 +92,21 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, clientId, isBackBoardOrAllBoard, nullptr);
|
||||
|
||||
// 将 ClientHandler 移动到线程池中的线程
|
||||
// 将 ClientHandler 移到线程池中的线程
|
||||
handler->moveToThread(thread);
|
||||
|
||||
// 当线程结束时删除 handler
|
||||
connect(thread, &QThread::finished, this, [=]() {
|
||||
onThreadFinished(thread, handler);
|
||||
});
|
||||
// 创建 DataHandler 对象并连接信号
|
||||
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel,
|
||||
VideoResolutionEdit,
|
||||
licenseHwInfoEdit, &devInfoLineEdits,
|
||||
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||
frontBoardDevInfoJson, frontBoardLicenseJson,
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, nullptr);
|
||||
qDebug() << "dataHandler->moveToThread(thread)";
|
||||
// 将 DataHandler 移到线程池中的线程
|
||||
dataHandler->moveToThread(thread);
|
||||
|
||||
|
||||
// 将sendData信号连接到主线程中的槽上
|
||||
connect(handler, &ClientHandler::sendData, this, [socket](const QByteArray& data, int isBoardType) {
|
||||
@@ -160,9 +136,6 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
this->onStartTimeout(clientId, timeout);
|
||||
});
|
||||
|
||||
// 启动新的线程
|
||||
thread->start();
|
||||
|
||||
clients.append(handler);
|
||||
clients_1[clientId] = handler;
|
||||
clientThreads[clientId] = thread;
|
||||
@@ -171,22 +144,23 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
connect(handler, &ClientHandler::allItemsProcessed, this, &MainWidget::onAllItemsProcessed);
|
||||
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
|
||||
|
||||
#if 1
|
||||
// 创建 DataHandler 对象并连接信号
|
||||
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, licenseHwInfoEdit, &devInfoLineEdits,
|
||||
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||
frontBoardDevInfoJson, frontBoardLicenseJson,
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, this);
|
||||
|
||||
dataHandlers[clientId] = dataHandler;
|
||||
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
|
||||
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
||||
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
||||
#else
|
||||
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
||||
#endif
|
||||
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
||||
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
||||
// 当线程结束时删除 handler
|
||||
connect(thread, &QThread::finished, this, [=]() {
|
||||
onThreadFinished(thread, handler, dataHandler);
|
||||
});
|
||||
// 启动新的线程
|
||||
thread->start();
|
||||
|
||||
connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer);
|
||||
connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer);
|
||||
//handler->getClientId() == handler->preVideoClientId
|
||||
qDebug() << "---- handler->getClientId():" << handler->getClientId();
|
||||
qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId;
|
||||
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
|
||||
|
||||
// 创建和管理定时器
|
||||
QTimer* readTimer = new QTimer(this);
|
||||
@@ -924,13 +898,20 @@ void MainWidget::onLicenseButtonClicked()
|
||||
QString dataStr = "";
|
||||
if (jsonObject["lable"].toString() == "get_license") {
|
||||
QString hwInfoText = licenseHwInfoEdit->toPlainText();
|
||||
if (hwInfoText.count("0x") != PIX_HARDWARE_INFO_BYTES) {
|
||||
isRequestSuccessful = 0;
|
||||
//licenseHwInfoEdit->setPlainText("您使用了License去获取License,这是不允许的!!!");
|
||||
LicenseConfirmWindow dialog("您使用了License去获取License,这是不允许的!!!");
|
||||
dialog.exec();
|
||||
return;
|
||||
}
|
||||
dataStr = hwInfoText.remove(","); // 去掉所有的逗号
|
||||
QString sendToHttpServerDataStr = dataStr.replace("0x", "").replace(" ", ""); // 去掉0x和空格
|
||||
#if 1
|
||||
qDebug() << "sendToHttpServerDataStr:" << sendToHttpServerDataStr;
|
||||
FactoryToolSendGetLicenseToHttpServer(sendToHttpServerDataStr);
|
||||
while (isRequestSuccessful == 0) {
|
||||
QCoreApplication::processEvents(); // 防止阻塞UI线程
|
||||
QCoreApplication::processEvents(); // 防止阻塞线程
|
||||
}
|
||||
qDebug() << "isRequestSuccessful:" << isRequestSuccessful;
|
||||
if (isRequestSuccessful == 2) {
|
||||
@@ -960,18 +941,18 @@ void MainWidget::onLicenseButtonClicked()
|
||||
qDebug() << "License Key set in licenseHwInfoEdit:" << licenseKey;
|
||||
return;
|
||||
#endif
|
||||
QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8());
|
||||
QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8());
|
||||
memcpy(hardware_info, dataByteArray.data(), qMin(dataByteArray.size(), PIX_HARDWARE_INFO_BYTES));
|
||||
//unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { 0x46,0x0b,0x5d,0x11,0x58,0x17,0x4d,0x5e,0x55,0x5c,0x51,0x4a,0x5a,0x07,0x59,0x4c,0x5f,0x45,0x5b,0x5f,0x5a,0x45,0x1c,0x5a,0x45,0x43,0x44,0x47,0x51,0x5e,0x44,0x30 };
|
||||
LicenseConfirmWindow dialog("你确定要获取此授权吗?\n请确认你的hw_info是否正确");
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
#if !MANUAL_UPLOAD_LICENSE
|
||||
if (!(licenseGenerate(hardware_info, license_info))) {
|
||||
qDebug() << "从U盘获取License失败" ;
|
||||
qDebug() << "从U盘获取License失败";
|
||||
isRequestSuccessful = 0;
|
||||
licenseHwInfoEdit->setPlainText("从U盘获取License失败,请检查U盘是否插入电脑!!!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
QString licenseInfoHex = QByteArray(reinterpret_cast<char*>(license_info), PIX_LICENCE_BYTES).toHex().toUpper();
|
||||
#else
|
||||
//unsigned char license_info_1[PIX_LICENCE_BYTES] = { 0x07, 0xe8, 0xf3, 0x80, 0xa8, 0x07, 0x72, 0xa1, 0x17, 0xfe, 0xda, 0x67, 0xbd, 0x4a, 0x5a, 0xb5, 0xbb, 0x8b, 0x2d, 0xb2, 0xbf, 0x89, 0x74, 0xe5, 0xb0, 0x99, 0x70, 0x74, 0x3c, 0x6f, 0xf8, 0x82, 0x79, 0xab, 0x31, 0x9c, 0xdf, 0xe8, 0x9e, 0x75, 0x8f, 0x42, 0xb3, 0xcf, 0x00, 0x60, 0xa0, 0x38, 0xa4, 0xb8, 0xbe, 0xa6, 0x5d, 0x9f, 0x8b, 0x41, 0xf3, 0x0a, 0x69, 0xf6, 0x50, 0x94, 0x3f, 0xd0, 0xa5, 0xee, 0x88, 0x20, 0x93, 0x9a, 0x1c, 0xe9, 0x64, 0xd3, 0xaf, 0x9f, 0xc7, 0x66, 0x00, 0x7d, 0x7d, 0x68, 0xf1, 0xa4, 0xe1, 0x58, 0x00, 0x1d, 0x03, 0x0d, 0x40, 0x08, 0xa4, 0xcc, 0x0b, 0xd8, 0x19, 0x70, 0x9a, 0x83, 0x81, 0xbf, 0x27, 0x35, 0xb8, 0xec, 0x59, 0xa8, 0xd0, 0x03, 0xdb, 0xf6, 0xcf, 0x83, 0xaa, 0x0e, 0xfc, 0x95, 0x29, 0x77, 0xec, 0x89, 0xc5, 0x79, 0x10, 0x40, 0xd8, 0xbb };
|
||||
@@ -995,7 +976,7 @@ void MainWidget::onLicenseButtonClicked()
|
||||
printf("\n");
|
||||
licenseHwInfoEdit->setPlainText(licenseInfoStr);
|
||||
isRequestSuccessful = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if 0
|
||||
@@ -1211,6 +1192,9 @@ void MainWidget::onSendGetPicClicked()
|
||||
button->setStyleSheet("background-color: green;");
|
||||
if (lastClickedGetPicCamIndex != -1 && lastClickedGetPicCamIndex != itemIndex) {
|
||||
getPicButtons[lastClickedGetPicCamIndex]->setStyleSheet("");
|
||||
if (lastClickedGetPicDevIndex != -1) {
|
||||
getPicButtons[lastClickedGetPicDevIndex]->setStyleSheet("");
|
||||
}
|
||||
}
|
||||
lastClickedGetPicCamIndex = itemIndex;
|
||||
}
|
||||
@@ -1254,26 +1238,27 @@ void MainWidget::onSendGetVideoClicked()
|
||||
QPushButton* button = qobject_cast<QPushButton*>(sender());
|
||||
int itemIndex = button->property("getVideoIndex").toInt();
|
||||
|
||||
if (itemIndex < 2) {
|
||||
if (itemIndex < 4) {
|
||||
button->setStyleSheet("background-color: green;");
|
||||
if (lastClickedGetVideoCamIndex != -1 && lastClickedGetVideoCamIndex != itemIndex) {
|
||||
getVideoButtons[lastClickedGetVideoCamIndex]->setStyleSheet("");
|
||||
if (lastClickedGetVideoDevIndex != -1) {
|
||||
getVideoButtons[lastClickedGetVideoDevIndex - 2]->setStyleSheet("");
|
||||
}
|
||||
}
|
||||
lastClickedGetVideoCamIndex = itemIndex;
|
||||
}
|
||||
else {
|
||||
if (lastClickedGetVideoCamIndex == -1) {
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("Please select IR or RGB lens to get video!!!"), statusListWidget);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("Please select lens to get video!!!"), statusListWidget);
|
||||
listItem->setBackground(Qt::red);
|
||||
}
|
||||
else {
|
||||
if (itemIndex - 6 >= connectedClientsCount) {
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("This device is not connected !!!").arg(itemIndex - 4), statusListWidget);
|
||||
if (itemIndex - 8 >= connectedClientsCount) {
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("This device is not connected !!!").arg(itemIndex - 6), statusListWidget);
|
||||
listItem->setBackground(Qt::red);
|
||||
}
|
||||
else {
|
||||
//qDebug() << "lastClickedGetVideoDevIndex:" << lastClickedGetVideoDevIndex;
|
||||
//qDebug() << "itemIndex:" << itemIndex;
|
||||
button->setStyleSheet("background-color: green;");
|
||||
if (lastClickedGetVideoDevIndex != -1 && lastClickedGetVideoDevIndex != itemIndex) {
|
||||
//qDebug() << "itemIndex:" << itemIndex;
|
||||
@@ -1283,11 +1268,11 @@ void MainWidget::onSendGetVideoClicked()
|
||||
//QMutexLocker locker(&mutex);
|
||||
for (ClientHandler* handler : clients) {
|
||||
if (handler->getClientId() == handler->controlClientId) {
|
||||
handler->sendGetVideoItem(itemIndex - 5, lastClickedGetVideoCamIndex);
|
||||
handler->sendGetVideoItem(itemIndex - 7, lastClickedGetVideoCamIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
getVideoButtons[2]->setEnabled(true);
|
||||
getVideoButtons[FOCUS_WINDOWS_BUTTON]->setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1303,9 +1288,15 @@ void MainWidget::onOpenFocusWindowClicked()
|
||||
QPushButton* button = qobject_cast<QPushButton*>(sender());
|
||||
if (button) {
|
||||
int itemIndex = button->property("getVideoIndex").toInt();
|
||||
//qDebug() << "New Button clicked with itemIndex:" << itemIndex;
|
||||
if (itemIndex == 2) {
|
||||
emit openFocusWindowRequested(itemIndex); // 发送信号
|
||||
qDebug() << "New Button clicked with itemIndex:" << itemIndex;
|
||||
if (itemIndex == FOCUS_WINDOWS_BUTTON) {
|
||||
for (ClientHandler* handler : clients) {
|
||||
if (handler->getClientId() == handler->preVideoClientId) {
|
||||
emit openFocusWindowRequested(itemIndex); // 发送信号
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "../Network/mdns/servicemodel.h"
|
||||
#include "../Network/ClientHandler.h"
|
||||
#include "../Network/httpClient.h"
|
||||
#include "FocusWindow.h"
|
||||
|
||||
|
||||
#include "../Network/mdns/qmdnsengine/include/server.h"
|
||||
@@ -63,8 +62,8 @@
|
||||
|
||||
#define TEST_UDP_BROADCAST 0 // 用于测试 UDP 组播实现 mdns 功能 非标准 mdns
|
||||
#define MANUAL_UPLOAD_LICENSE 0 // 打开手动上传 License的功能
|
||||
#define START_MDNS 1
|
||||
|
||||
#define START_MDNS 1
|
||||
#define FOCUS_WINDOWS_BUTTON 4 // 大窗口播放视频的按键编号
|
||||
#define TCP_CONNECT_PORT 12412 // TCP监听的端口
|
||||
|
||||
class MainWidget : public QWidget
|
||||
@@ -209,6 +208,8 @@ private:
|
||||
QPushButton* selectFileButton; // Save Log 按键
|
||||
QPushButton* clearLogButton; // clear Log 按键
|
||||
QLineEdit* filePathLineEdit; // 文件路径显示
|
||||
QLineEdit* VideoResolutionEdit; // 视频分辨率显示
|
||||
//QLineEdit* frameRateEdit; // 视频帧率显示
|
||||
QLabel* leftLens_imageLabel; // 左边镜头图像显示
|
||||
QLabel* rightLens_imageLabel; // 右边镜头图像显示
|
||||
QLabel* videoLabel; // 视频显示
|
||||
|
||||
@@ -186,7 +186,6 @@ QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig,
|
||||
return functionConfigTab;
|
||||
}
|
||||
|
||||
|
||||
QWidget* MainWidget::createImageDisplayTab()
|
||||
{
|
||||
QWidget* imageDisplayTab = new QWidget(this);
|
||||
@@ -245,13 +244,16 @@ QWidget* MainWidget::createVideoDisplayTab()
|
||||
QWidget* videoDisplayTab = new QWidget(this);
|
||||
QVBoxLayout* videoDisplayLayout = new QVBoxLayout(videoDisplayTab);
|
||||
QVBoxLayout* videoButtonsColumnLayout = new QVBoxLayout;
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
QHBoxLayout* videoButtonsRowLayout = new QHBoxLayout;
|
||||
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QPushButton* button;
|
||||
|
||||
if (i == 0 && j == 0) {
|
||||
button = new QPushButton(QString("左边镜头"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
button = new QPushButton(QString("猫眼镜头(IR)"), this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
@@ -259,8 +261,8 @@ QWidget* MainWidget::createVideoDisplayTab()
|
||||
continue;
|
||||
}
|
||||
else if (i == 0 && j == 1) {
|
||||
button = new QPushButton(QString("右边镜头"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
button = new QPushButton(QString("猫眼镜头(RGB)"), this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
@@ -268,27 +270,47 @@ QWidget* MainWidget::createVideoDisplayTab()
|
||||
continue;
|
||||
}
|
||||
|
||||
// 调价调焦窗口按键
|
||||
if (i == 1 && j == 0) {
|
||||
button = new QPushButton(QString("左边镜头"), this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
getVideoButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
else if (i == 1 && j == 1) {
|
||||
button = new QPushButton(QString("右边镜头"), this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
getVideoButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == 2 && j == 0) {
|
||||
button = new QPushButton(QString("大窗口播放视频"), this);
|
||||
button->setFixedSize(150, 50);
|
||||
button->setFixedSize(224, 50);
|
||||
button->setEnabled(false);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onOpenFocusWindowClicked);
|
||||
getVideoButtons.append(button);
|
||||
break; // 跳出内层循环,只添加一个按键
|
||||
}
|
||||
if (i >= 2 && i <= 5) {
|
||||
if(j == 0)
|
||||
button = new QPushButton(QString("Device %1\n打开视频").arg(i - 1), this);
|
||||
else if(j == 1)
|
||||
button = new QPushButton(QString("Device %1\n关闭视频").arg(i - 1), this);
|
||||
}
|
||||
|
||||
if (i >= 3 && i <= 5) {
|
||||
if (j == 0)
|
||||
button = new QPushButton(QString("Device %1\n打开视频").arg(i - 2), this);
|
||||
else if (j == 1)
|
||||
button = new QPushButton(QString("Device %1\n关闭视频").arg(i - 2), this);
|
||||
}
|
||||
else {
|
||||
button = new QPushButton(QString("Device %1").arg(i * 2 + (j * 1 - 1) - 3), this);
|
||||
}
|
||||
button->setFixedSize(73, 50);
|
||||
continue;
|
||||
}
|
||||
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j + 1);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
@@ -298,10 +320,23 @@ QWidget* MainWidget::createVideoDisplayTab()
|
||||
}
|
||||
|
||||
QHBoxLayout* videoAndButtonsLayout = new QHBoxLayout;
|
||||
QFormLayout* formLayout = new QFormLayout;
|
||||
QLabel* VideoResolution = new QLabel("分辨率:");
|
||||
VideoResolutionEdit = new QLineEdit;
|
||||
VideoResolutionEdit->setFixedWidth(120);
|
||||
formLayout->addRow(VideoResolution, VideoResolutionEdit);
|
||||
/*QLabel* frameRate = new QLabel("帧率:");
|
||||
frameRateEdit = new QLineEdit;
|
||||
frameRateEdit->setFixedWidth(120);
|
||||
formLayout->addRow(frameRate, frameRateEdit);*/
|
||||
videoLabel = new QLabel(this);
|
||||
videoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
videoAndButtonsLayout->addLayout(videoButtonsColumnLayout, 1);
|
||||
videoAndButtonsLayout->addWidget(videoLabel, 6);
|
||||
videoAndButtonsLayout->addLayout(videoButtonsColumnLayout);
|
||||
videoAndButtonsLayout->addLayout(formLayout);
|
||||
videoAndButtonsLayout->addWidget(videoLabel);
|
||||
videoAndButtonsLayout->setStretch(0, 1);
|
||||
videoAndButtonsLayout->setStretch(1, 1);
|
||||
videoAndButtonsLayout->setStretch(2, 1);
|
||||
videoDisplayLayout->addLayout(videoAndButtonsLayout);
|
||||
|
||||
return videoDisplayTab;
|
||||
|
||||
Reference in New Issue
Block a user