资源简介
Qt编写视频监控画面分割界面,支持四画面+六画面+八画面+九画面+十六画面,鼠标右键菜单切换。
代码片段和文件信息
#include “frmmain.h“
#include “ui_frmmain.h“
#pragma execution_character_set(“utf-8“)
frmMain::frmMain(QWidget *parent) :
QWidget(parent)
ui(new Ui::frmMain)
{
ui->setupUi(this);
this->initForm();
this->initMenu();
this->show_video_all();
QTimer::singleShot(1000 this SLOT(play_video_all()));
}
frmMain::~frmMain()
{
delete ui;
}
bool frmMain::eventFilter(Qobject *watched QEvent *event)
{
if (event->type() == QEvent::MouseButtondblclick) {
QLabel *widget = (QLabel *) watched;
if (!videoMax) {
videoMax = true;
hide_video_all();
ui->gridLayout->addWidget(widget 0 0);
widget->setVisible(true);
} else {
videoMax = false;
show_video_all();
}
} else if (event->type() == QEvent::MouseButtonPress) {
if (qApp->mouseButtons() == Qt::RightButton) {
videoMenu->exec(QCursor::pos());
}
}
return QWidget::eventFilter(watched event);
}
void frmMain::initForm()
{
//设置样式表
QStringList qss;
qss.append(“Qframe{border:2px solid #000000;}“);
qss.append(“QLabel{font:75 25px;color:#F0F0F0;border:2px solid #AAAAAA;background:#000000;}“);
qss.append(“QLabel:focus{border:2px solid #00BB9E;background:#555555;}“);
ui->frame->setstyleSheet(qss.join(““));
videoMax = false;
videoCount = 16;
videoType = “1_16“;
for (int i = 0; i < videoCount; i++) {
QLabel *widget = new QLabel;
widget->setobjectName(QString(“video%1“).arg(i + 1));
widget->installEventFilter(this);
widget->setFocusPolicy(Qt::StrongFocus);
widget->setAlignment(Qt::AlignCenter);
//二选一可以选择显示文字也可以选择显示背景图片
//widget->setText(QString(“通道 %1“).arg(i + 1));
widget->setPixmap(QPixmap(“:/bg_novideo.png“));
widgets.append(widget);
}
}
void frmMain::initMenu()
{
videoMenu = new QMenu(this);
videoMenu->addAction(“截图当前视频“ this SLOT(snapshot_video_one()));
videoMenu->addAction(“截图所有视频“ this SLOT(snapshot_video_all()));
videoMenu->addSeparator();
QMenu *menu4 = videoMenu->addMenu(“切换到4画面“);
menu4->addAction(“通道1-通道4“ this SLOT(show_video_4()));
menu4->addAction(“通道5-通道8“ this SLOT(show_video_4()));
menu4->addAction(“通道9-通道12“ this SLOT(show_video_4()));
menu4->addAction(“通道13-通道16“ this SLOT(show_video_4()));
QMenu *menu6 = videoMenu->addMenu(“切换到6画面“);
menu6->addAction(“通道1-通道6“ this SLOT(show_video_6()));
menu6->addAction(“通道6-通道11“ this SLOT(show_video_6()));
menu6->addAction(“通道11-通道16“ this SLOT(show_video_6()));
QMenu *menu8 = videoMenu->addMenu(“切换到8画面“);
menu8->addAction(“通道1-通道8“ this SLOT(show_video_8()));
menu8->addAction(“通道9-通道16“ this SLOT(show_video_8()));
QMenu *menu9 = videoMenu->addMenu(“切换到9画面“);
menu9->addAction(“通道1-通
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-01 14:16 video_splite\
文件 4851 2018-04-27 11:31 video_splite\bg_novideo.png
文件 10879 2018-05-01 13:57 video_splite\frmmain.cpp
文件 1141 2018-04-30 19:10 video_splite\frmmain.h
文件 1614 2018-05-01 13:58 video_splite\frmmain.ui
文件 745 2018-05-01 13:57 video_splite\main.cpp
文件 98 2018-04-28 13:26 video_splite\main.qrc
目录 0 2018-04-30 19:15 video_splite\snap\
文件 54226 2018-04-30 19:14 video_splite\snap\QQ截图20180430191412.png
文件 43252 2018-04-30 19:14 video_splite\snap\QQ截图20180430191420.png
文件 50975 2018-04-30 19:14 video_splite\snap\QQ截图20180430191429.png
文件 56021 2018-04-30 19:14 video_splite\snap\QQ截图20180430191440.png
文件 50772 2018-04-30 19:14 video_splite\snap\QQ截图20180430191448.png
文件 29113 2018-04-30 19:15 video_splite\snap\QQ截图20180430191527.png
文件 610 2018-05-01 13:53 video_splite\video_splite.pro
- 上一篇:win32-API-简明教程入门学习最佳教程
- 下一篇:Qt实现的FlatUI样式
评论
共有 条评论