欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

Qt视频播放器界面Demo

发布时间:2023/12/10 编程问答 50 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Qt视频播放器界面Demo 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

QMPlayer

Qt实现的视频播放器界面Demo。

文章目录

    • QMPlayer
      • 1、实现功能
      • 2、演示
      • 3、动画效果代码
      • 4、源代码

更多精彩内容
👉个人内容分类汇总 👈

1、实现功能

  • 基于QMWidget的自定义窗口;
  • 增加侧边栏模块;
  • 增加播放控制栏模块,包含播放停止、上一集、下一集、视频时间、音量控制、设置功能按键样式
  • 增加进度条模块,可跳转到鼠标点击位置
  • 通过QPropertyAnimation实现侧边栏、进度条、控制栏打开关闭动画效果;
  • 实现双击全屏显示、还原效果。

2、演示

3、动画效果代码

#include "controlbar.h" #include "ui_controlbar.h"#include <qdebug.h> #include <qpropertyanimation.h> #include <QStyle>ControlBar::ControlBar(QWidget *parent) :QWidget(parent),ui(new Ui::ControlBar) {ui->setupUi(this);m_paShow = new QPropertyAnimation(this, "pos");m_paShow->setDuration(500);connect(m_paShow, &QPropertyAnimation::finished, this, &ControlBar::on_finished);}ControlBar::~ControlBar() {delete ui; }/*** @brief 打开显示动画(注意必须放在窗口改变后面,如全屏显示、还原)*/ void ControlBar::show() {QWidget::show();int y = this->parentWidget()->height() - this->height() - 20;m_paShow->setStartValue(QPoint(this->x(), this->parentWidget()->height()));m_paShow->setEndValue(QPoint(this->x(), y));m_paShow->setEasingCurve(QEasingCurve::OutQuad);m_paShow->start(); }/*** @brief 关闭显示动画(注意必须放在窗口改变后面,如全屏显示、还原)*/ void ControlBar::hide() {int y = this->parentWidget()->height() - this->height() - 20;m_paShow->setStartValue(QPoint(this->x(), y));m_paShow->setEndValue(QPoint(this->x(), this->parentWidget()->height()));m_paShow->setEasingCurve(QEasingCurve::Linear);m_paShow->start(); }void ControlBar::on_finished() {if(m_paShow->endValue().toPoint().y() == this->parentWidget()->height()){QWidget::hide();} }void ControlBar::on_but_play_clicked() {if(m_play){}else{}m_play = !m_play;ui->but_play->setProperty("play", m_play);ui->but_play->style()->polish(ui->but_play); }void ControlBar::on_but_volume_clicked() {m_volume = !m_volume;ui->but_volume->setProperty("setup", m_volume);ui->but_volume->style()->polish(ui->but_volume); }

4、源代码

gitee
github

总结

以上是生活随笔为你收集整理的Qt视频播放器界面Demo的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。