Skip to content

Commit

Permalink
新增通用视频控件
Browse files Browse the repository at this point in the history
  • Loading branch information
feiyangqingyun committed Dec 19, 2019
1 parent ff16b64 commit 37af550
Show file tree
Hide file tree
Showing 9 changed files with 1,306 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| 27 | emailtool | 邮件发送工具 |
| 28 | ntpclient | NTP服务器时间同步 |
| 29 | lunarcalendarwidget | 农历控件 |
| 30 | videowidget | 通用视频控件 |

![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lightbutton.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/movewidget.gif)
Expand Down Expand Up @@ -59,4 +60,5 @@
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/mouseline.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/emailtool.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/ntpclient.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lunarcalendarwidget.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lunarcalendarwidget.gif)
![avatar](https://github.com/feiyangqingyun/QWidgetDemo/raw/master/snap/videowidget.gif)
Binary file added snap/videowidget.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions videowidget/frmvideowidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma execution_character_set("utf-8")

#include "frmvideowidget.h"
#include "ui_frmvideowidget.h"

frmVideoWidget::frmVideoWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmVideoWidget)
{
ui->setupUi(this);
this->initForm();
}

frmVideoWidget::~frmVideoWidget()
{
delete ui;
}

void frmVideoWidget::initForm()
{
ui->videoWidget1->setFlowEnable(true);
ui->videoWidget2->setFlowEnable(true);
ui->videoWidget3->setFlowEnable(true);
ui->videoWidget4->setFlowEnable(true);

connect(ui->videoWidget1, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString)));
connect(ui->videoWidget2, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString)));
connect(ui->videoWidget3, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString)));
connect(ui->videoWidget4, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString)));
}

void frmVideoWidget::btnClicked(const QString &objName)
{
VideoWidget *videoWidget = (VideoWidget *)sender();
QString str = QString("当前单击了控件 %1 的按钮 %2").arg(videoWidget->objectName()).arg(objName);
ui->label->setText(str);
}
26 changes: 26 additions & 0 deletions videowidget/frmvideowidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef FRMVIDEOWIDGET_H
#define FRMVIDEOWIDGET_H

#include <QWidget>

namespace Ui {
class frmVideoWidget;
}

class frmVideoWidget : public QWidget
{
Q_OBJECT

public:
explicit frmVideoWidget(QWidget *parent = 0);
~frmVideoWidget();

private:
Ui::frmVideoWidget *ui;

private slots:
void initForm();
void btnClicked(const QString &objName);
};

#endif // FRMVIDEOWIDGET_H
85 changes: 85 additions & 0 deletions videowidget/frmvideowidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>frmVideoWidget</class>
<widget class="QWidget" name="frmVideoWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="VideoWidget" name="videoWidget2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="VideoWidget" name="videoWidget1" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="VideoWidget" name="videoWidget4" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="VideoWidget" name="videoWidget3" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VideoWidget</class>
<extends>QWidget</extends>
<header>videowidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
32 changes: 32 additions & 0 deletions videowidget/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma execution_character_set("utf-8")

#include "frmvideowidget.h"
#include <QApplication>
#include <QTextCodec>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setFont(QFont("Microsoft Yahei", 9));

#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
#if _MSC_VER
QTextCodec *codec = QTextCodec::codecForName("gbk");
#else
QTextCodec *codec = QTextCodec::codecForName("utf-8");
#endif
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
#else
QTextCodec *codec = QTextCodec::codecForName("utf-8");
QTextCodec::setCodecForLocale(codec);
#endif

frmVideoWidget w;
w.setWindowTitle("视频监控控件");
w.resize(800, 600);
w.show();

return a.exec();
}
Loading

0 comments on commit 37af550

Please sign in to comment.