Qt视频播放器界面Demo
生活随笔
收集整理的這篇文章主要介紹了
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1812):前端调试之shad
- 下一篇: 前端学习(1764):前端调试值之性能分