1.运行界面
2.源码
//.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
//.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QGraphicsDropShadowEffect>
#include <QColor>
const int g_maxValue = 50;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setStyleSheet("background-color: rgb(255, 255, 255);");
ui->frame->setStyleSheet("background-color: rgb(0, 0, 0);");
ui->frame->setStyleSheet("border-radius:8px;");
//设置具体阴影
QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
shadow_effect->setOffset(0, 0);
//阴影颜色
shadow_effect->setColor(QColor(38, 78, 119, 127));
//阴影半径
shadow_effect->setBlurRadius(22);
ui->frame->setGraphicsEffect(shadow_effect);
}
Widget::~Widget()
{
delete ui;
}