1 Star 0 Fork 0

陈天灿/musicPlayer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Topwidget.cpp 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
陈天灿 提交于 2023-12-24 11:03 . first common
#include "head.h"
TopWidget::TopWidget()
{
// setStyleSheet("QLabel {background-color: white;}");//设置样式
// setAutoFillBackground(true);//执行填充
setAttribute(Qt::WA_TranslucentBackground, true);
}
void TopWidget::setText(const QString &textUp,const QString &textLower)
{
_textUp = textUp;
_textLower = textLower;
repaint();
}
void TopWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter paintor(this);
paintor.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform, true);
paintor.save();
paintor.setPen(QColor(Qt::white));
paintor.setFont(QFont("Arial", 15, 50));
auto original = rect();
auto upRect = QRect(original.x(), original.y(), original.width(), original.height() - 16);
paintor.drawText(upRect, Qt::AlignCenter, _textUp);
paintor.restore();
paintor.save();
auto LowerRect = QRect(original.x(), original.y() + upRect.height(), original.width(), 16);
paintor.setPen(QColor(Qt::white));
paintor.setFont(QFont("Arial",10,50));
paintor.drawText(LowerRect, Qt::AlignCenter, _textLower);
paintor.restore();
}
TopWidget::~TopWidget()
{
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/chen_tiancan/music-player.git
git@gitee.com:chen_tiancan/music-player.git
chen_tiancan
music-player
musicPlayer
master

搜索帮助