Push layered Qt host source files
This commit is contained in:
@@ -7,9 +7,7 @@ namespace APP {
|
||||
APP_GlassCard::APP_GlassCard(QWidget* parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
// 交给我们自己统一绘制卡片外观,不使用 QFrame 默认边框。
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
// 背景由 paintEvent 自绘,这里不走样式表背景。
|
||||
setAttribute(Qt::WA_StyledBackground, false);
|
||||
}
|
||||
|
||||
@@ -17,11 +15,6 @@ void APP_GlassCard::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
/*
|
||||
* 卡片外观刻意保持简单,方便教学时理解自绘流程:
|
||||
* 1. 先画一个带圆角的深色底板
|
||||
* 2. 再画一圈细边框
|
||||
*/
|
||||
const QRectF BodyRect = rect().adjusted(1.0, 1.0, -1.0, -1.0);
|
||||
const qreal Radius = 22.0;
|
||||
const QColor FillColor(30, 35, 43);
|
||||
@@ -29,12 +22,9 @@ void APP_GlassCard::paintEvent(QPaintEvent* event)
|
||||
|
||||
QPainter Painter(this);
|
||||
Painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// 先画卡片主体。
|
||||
Painter.setPen(QPen(BorderColor, 1.0));
|
||||
Painter.setBrush(FillColor);
|
||||
Painter.drawRoundedRect(BodyRect, Radius, Radius);
|
||||
|
||||
}
|
||||
|
||||
} // namespace APP
|
||||
|
||||
Reference in New Issue
Block a user