1 Star 0 Fork 7

elee/qkuwoplayer

forked from lynnhua/qkuwoplayer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qtmenuwidget.cpp 2.49 KB
一键复制 编辑 原始数据 按行查看 历史
lynnhua 提交于 2022-09-22 10:57 . add mute ctrl
/******************************************************************
*Company: http://www.xiaomutech.com/
*fileName : qtmenuwidget.cpp --- QtMenuWidget
*Auth : yhni (QQ:393320854)
*Create : 2022/9/21
*Description :
*Histroy:
*<Auth> <Date> <Ver> <Content>
* 2022/9/21
*******************************************************************/
#include "qtmenuwidget.h"
#include <QPainter>
#include <QBoxLayout>
QtMenuWidget::QtMenuWidget(QWidget *_centerWidget, QWidget *parent) : QMenu(parent)
{
m_direction = Top;
m_centerWidget = _centerWidget;
setWindowFlags(this->windowFlags() | Qt::NoDropShadowWindowHint);
if (NULL != _centerWidget)
{
QHBoxLayout *horlayout = new QHBoxLayout(this);
horlayout->setContentsMargins(5, 5, 5, 5);
horlayout->addWidget(_centerWidget);
}
}
QtMenuWidget::~QtMenuWidget()
{
}
void QtMenuWidget::setDireciton(int _dir)
{
m_direction = _dir;
this->update();
}
void QtMenuWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(this->rect(), QColor("#fafafa"));
QPainterPath path;
if (Left == m_direction)
{
path.addRoundedRect(8, 1, this->width() - 10, this->height() - 2, 5, 5);
path.moveTo(8, this->height() * 0.5 - 4);
path.lineTo(1, this->height() * 0.5);
path.lineTo(8, this->height() * 0.5 + 4);
}
else if (Top == m_direction)
{
path.addRoundedRect(1, 8, this->width() - 2, this->height() - 10, 5, 5);
path.moveTo(this->width() * 0.5 - 4, 8);
path.lineTo(this->width() * 0.5, 1);
path.lineTo(this->width() * 0.5 + 4, 8);
}
else if (Right == m_direction){
path.addRoundedRect(1, 1, this->width() - 10, this->height() - 2, 5, 5);
path.moveTo(this->width() - 8, this->height() * 0.5 - 4);
path.lineTo(this->width() - 1, this->height() * 0.5);
path.lineTo(this->width() - 8, this->height() * 0.5 + 4);
}
else if (Bottom == m_direction){
QRect rect(1, 1, this->width() - 2, this->height() - 2 - 8);
path.addRoundedRect(rect, 5, 5);
path.moveTo(this->width() * 0.5 - 5, rect.bottom() + 1);
path.lineTo(this->width() * 0.5, this->height() - 2);
path.lineTo(this->width() * 0.5 + 5, rect.bottom() + 1);
}
path.closeSubpath();
painter.setPen(QColor("#e1e1e1"));
painter.setBrush(QColor("#ffffff"));
painter.drawPath(path.simplified());
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qwert123123/qkuwoplayer.git
git@gitee.com:qwert123123/qkuwoplayer.git
qwert123123
qkuwoplayer
qkuwoplayer
master

搜索帮助