qt-material-widgets/components/appbar.cpp

42 lines
878 B
C++
Raw Normal View History

2016-03-19 08:53:28 +00:00
#include <QGraphicsDropShadowEffect>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
2016-03-19 08:32:49 +00:00
#include "appbar.h"
2016-03-19 08:53:28 +00:00
AppBar::AppBar(QWidget *parent)
: QWidget(parent)
{
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
effect->setOffset(0, 2);
effect->setBlurRadius(11);
effect->setColor(QColor(0, 0, 0, 50));
setGraphicsEffect(effect);
QHBoxLayout *layout = new QHBoxLayout;
setLayout(layout);
QLabel *label = new QLabel("App");
layout->addWidget(label);
2016-03-19 09:03:38 +00:00
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum));
2016-03-19 08:53:28 +00:00
setMinimumHeight(64);
}
AppBar::~AppBar()
{
}
void AppBar::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(Qt::white);
painter.fillRect(rect(), brush);
}