视频监控系统中,除了常规的1画面、4画面、9画面、16画面以外,还有几个布局比较另类,比如6画面、8画面、13画面,有些通道需要占据不同的行列,4画面、9画面、16画面都是非常对称的布局,行数和列数都一样,而且每个通道占据的面积都一样,初学者都知道怎么处理。而其他几种布局就需要先在头脑中或者纸上规划好哪个通道占用多大面积,占用几行几列,Qt的表格布局非常强大,除了最常用的横向布局和垂直布局以外,就属于表格布局用的最多了,用好了,各种异形效果都可以做出来,gridLayout的第四第五个参数就是用来控制当前控件占用的行数和列数,默认是1,表示占用1行1列,通过控制这两个参数,就可以非常方便的实现6画面、8画面、13画面的效果了。
体验地址:https://pan.baidu.com/s/1bbL2ZughZAgfIGrexyN-9g 提取码:zkeh 。
监控系统是由摄像、传输、控制、显示、记录登记5大部分组成。摄像机通过同轴视频电缆将视频图像传输到控制主机,控制主机再将视频信号分配到各监视器及录像设备,同时可将需要传输的语音信号同步录入到录像机内。 通过控制主机,操作人员可发出指令,对云台的上、下、左、右的动作进行控制及对镜头进行调焦变倍的操作,并可通过控制主机实现在多路摄像机及云台之间的切换。利用特殊的录像处理模式,可对图像进行录入、回放、处理等操作,使录像效果达到最佳。
视频监控系统由实时控制系统、监视系统及管理信息系统组成。实时控制系统完成实时数据采集处理、存储、反馈的功能;监视系统完成对各个监控点的全天候的监视,能在多操作控制点上切换多路图像;管理信息系统完成各类所需信息的采集、接收、传输、加工、处理,是整个系统的控制核心。视频监控系统是安全防范系统的组成部分,它是一种防范能力较强的综合系统。视频监控以其直观、方便、信息内容丰富而广泛应用于许多场合。
void frmVideoPanel::show_video_all()
{
if (App::VideoType.startsWith("0_")) {
QStringList list = App::VideoType.split("_");
int index = list.last().toInt() - 1;
hide_video_all();
ui->gridLayout->addWidget(widgets.at(index), 0, 0);
widgets.at(index)->setVisible(true);
ui->btnVideo1->setChecked(true);
} else if (App::VideoType == "1_4") {
change_video_4(0);
} else if (App::VideoType == "5_8") {
change_video_4(4);
} else if (App::VideoType == "9_12") {
change_video_4(8);
} else if (App::VideoType == "13_16") {
change_video_4(12);
} else if (App::VideoType == "1_6") {
change_video_6(0);
} else if (App::VideoType == "6_11") {
change_video_6(5);
} else if (App::VideoType == "11_16") {
change_video_6(10);
} else if (App::VideoType == "1_8") {
change_video_8(0);
} else if (App::VideoType == "9_16") {
change_video_8(8);
} else if (App::VideoType == "1_9") {
change_video_9(0);
} else if (App::VideoType == "8_16") {
change_video_9(7);
} else if (App::VideoType == "1_13") {
change_video_13(0);
} else if (App::VideoType == "4_16") {
change_video_13(3);
} else if (App::VideoType == "1_16") {
change_video_16(0);
}
}
void frmVideoPanel::show_video_4()
{
QString videoType;
int index = 0;
QAction *action = (QAction *)sender();
QString name = action->text();
if (name == "通道1-通道4") {
index = 0;
videoType = "1_4";
} else if (name == "通道5-通道8") {
index = 4;
videoType = "5_8";
} else if (name == "通道9-通道12") {
index = 8;
videoType = "9_12";
} else if (name == "通道13-通道16") {
index = 12;
videoType = "13_16";
}
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_4(index);
}
}
void frmVideoPanel::show_video_6()
{
QString videoType;
int index = 0;
QAction *action = (QAction *)sender();
QString name = action->text();
if (name == "通道1-通道6") {
index = 0;
videoType = "1_6";
} else if (name == "通道6-通道11") {
index = 5;
videoType = "6_11";
} else if (name == "通道11-通道16") {
index = 10;
videoType = "11_16";
}
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_6(index);
}
}
void frmVideoPanel::show_video_8()
{
QString videoType;
int index = 0;
QAction *action = (QAction *)sender();
QString name = action->text();
if (name == "通道1-通道8") {
index = 0;
videoType = "1_8";
} else if (name == "通道9-通道16") {
index = 8;
videoType = "9_16";
}
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_8(index);
}
}
void frmVideoPanel::show_video_9()
{
QString videoType;
int index = 0;
QAction *action = (QAction *)sender();
QString name = action->text();
if (name == "通道1-通道9") {
index = 0;
videoType = "1_9";
} else if (name == "通道8-通道16") {
index = 7;
videoType = "8_16";
}
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_9(index);
}
}
void frmVideoPanel::show_video_13()
{
QString videoType;
int index = 0;
QAction *action = (QAction *)sender();
QString name = action->text();
if (name == "通道1-通道13") {
index = 0;
videoType = "1_13";
} else if (name == "通道4-通道16") {
index = 3;
videoType = "4_16";
}
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_13(index);
}
}
void frmVideoPanel::show_video_16()
{
QString videoType;
int index = 0;
videoType = "1_16";
if (App::VideoType != videoType) {
App::VideoType = videoType;
App::VideoMax = false;
App::writeConfig();
change_video_16(index);
}
}
void frmVideoPanel::hide_video_all()
{
for (int i = 0; i < App::VideoCount; i++) {
ui->gridLayout->removeWidget(widgets.at(i));
widgets.at(i)->setVisible(false);
}
}
void frmVideoPanel::change_video(int index, int flag)
{
int count = 0;
int row = 0;
int column = 0;
for (int i = 0; i < App::VideoCount; i++) {
if (i >= index) {
ui->gridLayout->addWidget(widgets.at(i), row, column);
widgets.at(i)->setVisible(true);
count++;
column++;
if (column == flag) {
row++;
column = 0;
}
}
if (count == (flag * flag)) {
break;
}
}
}
void frmVideoPanel::change_video_4(int index)
{
ui->btnVideo4->setChecked(true);
hide_video_all();
change_video(index, 2);
}
void frmVideoPanel::change_video_6(int index)
{
ui->btnVideo6->setChecked(true);
hide_video_all();
if (index == 0) {
ui->gridLayout->addWidget(widgets.at(0), 0, 0, 2, 2);
ui->gridLayout->addWidget(widgets.at(1), 0, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(2), 1, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(3), 2, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(4), 2, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(5), 2, 0, 1, 1);
for (int i = 0; i < 6; i++) {
widgets.at(i)->setVisible(true);
}
} else if (index == 5) {
ui->gridLayout->addWidget(widgets.at(5), 0, 0, 2, 2);
ui->gridLayout->addWidget(widgets.at(6), 0, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(7), 1, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(8), 2, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(9), 2, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(10), 2, 0, 1, 1);
for (int i = 5; i < 11; i++) {
widgets.at(i)->setVisible(true);
}
} else if (index == 10) {
ui->gridLayout->addWidget(widgets.at(10), 0, 0, 2, 2);
ui->gridLayout->addWidget(widgets.at(11), 0, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(12), 1, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(13), 2, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(14), 2, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(15), 2, 0, 1, 1);
for (int i = 10; i < 16; i++) {
widgets.at(i)->setVisible(true);
}
}
}
void frmVideoPanel::change_video_8(int index)
{
ui->btnVideo8->setChecked(true);
hide_video_all();
if (index == 0) {
ui->gridLayout->addWidget(widgets.at(0), 0, 0, 3, 3);
ui->gridLayout->addWidget(widgets.at(1), 0, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(2), 1, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(3), 2, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(4), 3, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(5), 3, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(6), 3, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(7), 3, 0, 1, 1);
for (int i = 0; i < 8; i++) {
widgets.at(i)->setVisible(true);
}
} else if (index == 8) {
ui->gridLayout->addWidget(widgets.at(8), 0, 0, 3, 3);
ui->gridLayout->addWidget(widgets.at(9), 0, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(10), 1, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(11), 2, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(12), 3, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(13), 3, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(14), 3, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(15), 3, 0, 1, 1);
for (int i = 8; i < 16; i++) {
widgets.at(i)->setVisible(true);
}
}
}
void frmVideoPanel::change_video_9(int index)
{
ui->btnVideo9->setChecked(true);
hide_video_all();
change_video(index, 3);
}
void frmVideoPanel::change_video_13(int index)
{
ui->btnVideo13->setChecked(true);
hide_video_all();
if (index == 0) {
ui->gridLayout->addWidget(widgets.at(0), 0, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(1), 0, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(2), 0, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(3), 0, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(4), 1, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(5), 2, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(6), 1, 1, 2, 2);
ui->gridLayout->addWidget(widgets.at(7), 1, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(8), 2, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(9), 3, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(10), 3, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(11), 3, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(12), 3, 3, 1, 1);
for (int i = 0; i < 13; i++) {
widgets.at(i)->setVisible(true);
}
} else if (index == 3) {
ui->gridLayout->addWidget(widgets.at(3), 0, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(4), 0, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(5), 0, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(6), 0, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(7), 1, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(8), 2, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(9), 1, 1, 2, 2);
ui->gridLayout->addWidget(widgets.at(10), 1, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(11), 2, 3, 1, 1);
ui->gridLayout->addWidget(widgets.at(12), 3, 0, 1, 1);
ui->gridLayout->addWidget(widgets.at(13), 3, 1, 1, 1);
ui->gridLayout->addWidget(widgets.at(14), 3, 2, 1, 1);
ui->gridLayout->addWidget(widgets.at(15), 3, 3, 1, 1);
for (int i = 3; i < 16; i++) {
widgets.at(i)->setVisible(true);
}
}
}
void frmVideoPanel::change_video_16(int index)
{
ui->btnVideo16->setChecked(true);
hide_video_all();
change_video(index, 4);
}