forked from feiyangqingyun/QWidgetDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff16b64
commit 37af550
Showing
9 changed files
with
1,306 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
Oops, something went wrong.