#include "widget.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QMouseEvent>
#include <qdebug.h>
#include <QLabel>
#include <QFileDialog>
#include <QFileInfo>
#include <QMediaPlaylist>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->resize(800,500);
this->setWindowFlag(Qt::FramelessWindowHint);
CreateCenterWgt();
CreateTitleWgt();
CreateToolWgt();
QVBoxLayout *mainLayout=new QVBoxLayout(this);
mainLayout->addWidget(m_pTitleWgt);
mainLayout->addWidget(m_pToolWgt);
mainLayout->addWidget(m_pCenterWgt);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
this->setLayout(mainLayout);
MyThread *thread=new MyThread(this);
thread->start();
}
Widget::~Widget()
{
}
void Widget::CreateTitleWgt()
{
QFont textFont;
textFont.setPointSize(12);
textFont.setFamily("Microsoft YaHei");
m_pTitleWgt=new QWidget(this);
m_pTitleWgt->setFixedHeight(40);
QPushButton *minBtn=new QPushButton(this);
QPushButton *maxBtn=new QPushButton(this);
QPushButton *closeBtn=new QPushButton(this);
QLabel *iconLabel=new QLabel(this);
QLabel *textLabel=new QLabel(QStringLiteral("小俊播放器"));
minBtn->setFixedSize(40,40);
minBtn->setIcon(QIcon(":/Image/min.png"));
minBtn->setIconSize(QSize(32,32));
minBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
maxBtn->setFixedSize(40,40);
maxBtn->setIcon(QIcon(":/Image/max.png"));
maxBtn->setIconSize(QSize(32,32));
maxBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
closeBtn->setFixedSize(40,40);
closeBtn->setIcon(QIcon(":/Image/close.png"));
closeBtn->setIconSize(QSize(32,32));
closeBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
iconLabel->setFixedSize(40,40);
iconLabel->setPixmap(QPixmap(":/Image/mideaplay.png"));
textLabel->setFixedSize(100,40);
textLabel->setFont(textFont);
textLabel->setStyleSheet("color:white");
QHBoxLayout *titleLayout=new QHBoxLayout(this);
titleLayout->addWidget(iconLabel);
titleLayout->addWidget(textLabel);
titleLayout->addStretch();
titleLayout->addWidget(minBtn);
titleLayout->addWidget(maxBtn);
titleLayout->addWidget(closeBtn);
titleLayout->setMargin(0);
titleLayout->setSpacing(0);
m_pTitleWgt->setLayout(titleLayout);
m_pTitleWgt->setStyleSheet("background:rgb(69,133,254)");
connect(minBtn,&QPushButton::clicked,this,&Widget::onMinBtnClicked);
connect(maxBtn,&QPushButton::clicked,this,&Widget::onMaxorResetBtnClicked);
connect(closeBtn,&QPushButton::clicked,this,&Widget::onCloseBtnClicked);
}
void Widget::CreateToolWgt()
{
m_pToolWgt=new QWidget(this);
m_pToolWgt->setFixedHeight(50);
QPushButton *openFileBtn=new QPushButton(this);
openFileBtn->setFixedSize(50,50);
openFileBtn->setIcon(QIcon(":/Image/openfoder.png"));
openFileBtn->setIconSize(QSize(32,32));
openFileBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
QHBoxLayout *toolLayout=new QHBoxLayout(this);
toolLayout->addWidget(openFileBtn);
toolLayout->setMargin(0);
toolLayout->setSpacing(10);
toolLayout->addStretch();
m_pToolWgt->setLayout(toolLayout);
m_pToolWgt->setStyleSheet("background:white");
connect(openFileBtn,&QPushButton::clicked,this,&Widget::onOpenFileBtnClicked);
}
void Widget::CreateCenterWgt()
{
CreateControlWgt();
m_pCenterWgt=new QWidget(this);
m_pTreeWgt=new MyTreeWgt(this);
m_pRootItem=m_pTreeWgt->GetRootItem();
m_pTreeWgt->setFixedWidth(250);
m_pPlayer=new QMediaPlayer(this);
m_pVideoWgt=new MyVideoWgt(this);
m_pPlayer->setVideoOutput(m_pVideoWgt);
QWidget *rightWgt=new QWidget(this);
QVBoxLayout *rightLayout=new QVBoxLayout(this);
rightLayout->addWidget(m_pVideoWgt);
rightLayout->addWidget(m_pControlWgt);
rightLayout->setSpacing(0);
rightLayout->setMargin(0);
rightWgt->setLayout(rightLayout);
QHBoxLayout *centerLayout=new QHBoxLayout(this);
centerLayout->addWidget(m_pTreeWgt);
centerLayout->addWidget(rightWgt);
centerLayout->setMargin(0);
centerLayout->setSpacing(0);
m_pCenterWgt->setLayout(centerLayout);
connect(m_pTreeWgt,&QTreeWidget::itemDoubleClicked,this,&Widget::onTreeWgtItemDoubleClicked);
}
void Widget::CreateControlWgt()
{
m_pControlWgt=new QWidget(this);
m_pSlider=new QSlider(this);
m_pSlider->setRange(0,100);
m_pSlider->setOrientation(Qt::Horizontal);
m_pNextBtn=new QPushButton(this);
m_pLastBtn=new QPushButton(this);
m_pParseBtn=new QPushButton(this);
m_pResetBtn=new QPushButton(this);
m_pControlWgt->setFixedHeight(60);
m_pSlider->setStyleSheet("QSlider::handle:horizontal{width:24px;background-color:rgb(255,255,255);margin:-11px 0px -11px 0px;border-radius:12px;}"
"QSlider::groove:horizontal{height:2px;background-color:rgb(219,219,219);}"
"QSlider::add-page:horizontal{background-color:rgb(219,219,219);}"
"QSlider::sub-page:horizontal{background-color:rgb(26,217,110);}");
m_pNextBtn->setFixedSize(40,40);
m_pNextBtn->setIcon(QIcon(":/Image/next.png"));
m_pNextBtn->setIconSize(QSize(32,32));
m_pNextBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
m_pLastBtn->setFixedSize(40,40);
m_pLastBtn->setIcon(QIcon(":/Image/last.png"));
m_pLastBtn->setIconSize(QSize(32,32));
m_pLastBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
m_pParseBtn->setFixedSize(40,40);
m_pParseBtn->setIcon(QIcon(":/Image/start.png"));
m_pParseBtn->setIconSize(QSize(32,32));
m_pParseBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
m_pResetBtn->setFixedSize(40,40);
m_pResetBtn->setIcon(QIcon(":/Image/restart.png"));
m_pResetBtn->setIconSize(QSize(32,32));
m_pResetBtn->setStyleSheet("QPushButton{border:none;border-radius:5px}"
"QPushButton::hover{background:rgb(46,191,239)}");
QWidget *bottomWgt=new QWidget(this);
QHBoxLayout *bottomLayout=new QHBoxLayout(this);
bottomLayout->addStretch();
bottomLayout->addWidget(m_pLastBtn);
bottomLayout->addWidget(m_pParseBtn);
bottomLayout->addWidget(m_pResetBtn);
bottomLayout->addWidget(m_pNextBtn);
bottomLayout->setMargin(0);
bottomLayout->setSpacing(5);
bottomLayout->addStretch();
bottomWgt->setLayout(bottomLayout);
bottomWgt->setFixedHeight(40);
QVBoxLayout *controlLayout=new QVBoxLayout(this);
controlLayout->addWidget(m_pSlider);
controlLayout->addWidget(bottomWgt);
controlLayout->setMargin(0);
controlLayout->setSpacing(0);
m_pControlWgt->setLayout(controlLayout);
connect(m_pNextBtn,&QPushButton::clicked,this,&Widget::onNextBtnClicked);
connect(m_pLastBtn,&QPushButton::clicked,this,&Widget::onLastBtnClicked);
connect(m_pParseBtn,&QPushButton::clicked,this,&Widget::onParseBtnClicked);
connect(m_pResetBtn,&QPushButton::clicked,this,&Widget::onResetBtnClicked);
connect(m_pSlider,&QSlider::sliderMoved,this,&Widget::onSliderValueChanged);
}
void Widget::ResetTreeWgtSelected()
{
for(int i=0;i<m_pRootItem->childCoun
qtplayer.zip
版权申诉
5星 · 超过95%的资源 164 浏览量
2021-08-07
17:08:12
上传
评论 6
收藏 20KB ZIP 举报
加油吧,小杜
- 粉丝: 2557
- 资源: 26
最新资源
- 基于matlab开发的全面详解LTE:MATLAB建模、仿真与实现-simulink.rar
- 自动驾驶定位系列教程二:系统架构.pdf
- 整站程序8优技巧网-8ujq.rar
- 世界各个国家或地区国际域名缩写
- 基于matlab开发的根据rvm回归模型自己编的matlab程序.rar
- 基于matlab开发的该程序为国内一所大学编写的LTE链路层仿真程序,根据LTE标准协议编写的,很容易看懂.rar
- 高效C++学生成绩管理系统:教育技术+C++17编程+数据管理+教务自动化
- 搜索链接要广告分类系统 v2.0-yad20.rar
- 基于matlab开发的Tipping的相关向量机RVM的回归MATLAB程序,有英文注释,可以运行.rar
- 一个点击正反转程序实例,可实现案件电机正反转
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
前往页