直播平台制作,私密内容自带毛玻璃效果如何实现

直播平台制作,私密内容自带毛玻璃效果如何实现的相关代码

程序代码:

 

1
<br>#ifndef SYSDIALOG_H<br>#define SYSDIALOG_H<br> <br>#include <qdialog.h><br>#include <QGraphicsBlurEffect><br>#include <QGraphicsPixmapItem><br>#include <QPaintEvent><br>#include <QPainter><br>#include <QTimer><br>#include <QDebug><br>#include <QApplication><br>#include <QDesktopWidget><br>#include <QEvent><br>#include <QMouseEvent><br>#include <qscreen.h><br>#include <QHBoxLayout>//水平<br>#include <QVBoxLayout>//垂直<br>#include <qspinbox.h><br>class SysDialog : public QDialog<br>{<br>    Q_OBJECT<br> <br>public:<br>    explicit SysDialog(QWidget *parent = nullptr);<br>    ~SysDialog();<br>    void paintEvent(QPaintEvent *event);<br>private:<br>    QVBoxLayout *Main_VBoxLayout;<br>    QHBoxLayout *Main_HBoxLayout;<br>    QSpinBox    *Value_SpinBox;<br>    QColor bgColor;<br>private slots:<br>    void Value_SpinBox_valueChanged_Slot(int v);<br>};<br> <br>#endif // SYSDIALOG_H<br>#include "SysDialog.h"<br>#include <qthread.h><br>#include <Windows.h><br>//<br>enum AccentState<br>{<br>        ACCENT_DISABLED = 0,<br>        ACCENT_ENABLE_GRADIENT = 1,<br>        ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,<br>        ACCENT_ENABLE_BLURBEHIND = 3,<br>        ACCENT_INVALID_STATE = 4<br>};<br>struct AccentPolicy<br>{<br>        AccentState AccentState;<br>        int AccentFlags;<br>        int GradientColor;<br>        int AnimationId;<br>};<br>enum WindowCompositionAttribute<br>{<br>        WCA_UNDEFINED = 0,<br>        WCA_NCRENDERING_ENABLED = 1,<br>        WCA_NCRENDERING_POLICY = 2,<br>        WCA_TRANSITIONS_FORCEDISABLED = 3,<br>        WCA_ALLOW_NCPAINT = 4,<br>        WCA_CAPTION_BUTTON_BOUNDS = 5,<br>        WCA_NONCLIENT_RTL_LAYOUT = 6,<br>        WCA_FORCE_ICONIC_REPRESENTATION = 7,<br>        WCA_EXTENDED_FRAME_BOUNDS = 8,<br>        WCA_HAS_ICONIC_BITMAP = 9,<br>        WCA_THEME_ATTRIBUTES = 10,<br>        WCA_NCRENDERING_EXILED = 11,<br>        WCA_NCADORNMENTINFO = 12,<br>        WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,<br>        WCA_VIDEO_OVERLAY_ACTIVE = 14,<br>        WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,<br>        WCA_DISALLOW_PEEK = 16,<br>        WCA_CLOAK = 17,<br>        WCA_CLOAKED = 18,<br>        WCA_ACCENT_POLICY = 19,<br>        WCA_FREEZE_REPRESENTATION = 20,<br>        WCA_EVER_UNCLOAKED = 21,<br>        WCA_VISUAL_OWNER = 22,<br>        WCA_LAST = 23<br>};<br>struct WindowCompositionAttributeData<br>{<br>        WindowCompositionAttribute Attribute;<br>        int * Data;<br>        int SizeOfData;<br>};<br> <br>typedef int* (*pfun)(HWND hwnd, WindowCompositionAttributeData *data);<br>SysDialog::SysDialog(QWidget *parent)<br>    : QDialog(parent)<br>{<br> <br>//    setWindowFlags(Qt::FramelessWindowHint);<br>    HWND hWnd = HWND(winId());<br>    HMODULE hUser = GetModuleHandle(L"user32.dll");<br> <br>    if (hUser) {<br>        pfun setWindowCompositionAttribute = (pfun)GetProcAddress(hUser, "SetWindowCompositionAttribute");<br>        if (setWindowCompositionAttribute) {<br>//            AccentPolicy accent = { ACCENT_ENABLE_BLURBEHIND, 0x20 | 0x40 | 0x80 | 0x100, 0, 0 };<br>            AccentPolicy accent = { ACCENT_ENABLE_BLURBEHIND,0, 0, 0 };<br>            WindowCompositionAttributeData data;<br>            data.Attribute = WCA_ACCENT_POLICY;<br>            data.Data = reinterpret_cast<int *>(&accent) ;<br>            data.SizeOfData = sizeof(accent);<br>            setWindowCompositionAttribute(hWnd, &data);<br>        }<br>    }<br>    this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明<br>//    setWindowOpacity(1);<br>    setWindowTitle(QString(""));<br> <br>    Main_VBoxLayout = new QVBoxLayout(this);<br>    Main_HBoxLayout = new QHBoxLayout;<br>    Value_SpinBox   = new QSpinBox;<br>    Value_SpinBox->setMaximum(255);<br>    Value_SpinBox->setValue(50);<br>    connect(Value_SpinBox, SIGNAL(valueChanged(int)), this, SLOT(Value_SpinBox_valueChanged_Slot(int)));<br> <br> <br> <br>    Main_HBoxLayout->addWidget(Value_SpinBox,0);<br>    Main_HBoxLayout->addStretch();<br>    Main_HBoxLayout->setContentsMargins(0,0,0,0);<br>    Main_HBoxLayout->setSpacing(0);<br> <br> <br>    Main_VBoxLayout->addLayout(Main_HBoxLayout,0);<br>    Main_VBoxLayout->addStretch();<br>    Main_VBoxLayout->setContentsMargins(0,0,0,0);<br>    Main_VBoxLayout->setSpacing(0);<br>    resize(900,600);<br> <br>    //<br>    bgColor = QColor(255, 255, 255, 100);<br>}<br> <br>SysDialog::~SysDialog()<br>{<br>    delete Main_VBoxLayout;<br>}<br> <br>void SysDialog::Value_SpinBox_valueChanged_Slot(int v)<br>{<br>    qDebug()<<v;<br>    bgColor.setAlpha(v);<br>    update();<br>}<br> <br>/*<br> * Event Function<br> */<br>void SysDialog::paintEvent(QPaintEvent *event)<br>{<br>    static bool v = false;<br>    if (v) return;<br> <br>    QPainter painter(this);<br>    painter.setRenderHint(QPainter::Antialiasing);<br>    painter.setPen(Qt::NoPen);<br>    painter.setBrush(bgColor);<br>    painter.drawRoundedRect(rect(), 0, 0);<br>    v = true;<br>    //painter.fillRect(ui.frame->rect(), bgColor);<br>}<br> 

以上就是直播平台制作,私密内容自带毛玻璃效果如何实现的相关代码, 更多内容欢迎关注之后的文章

 

posted @   云豹科技-苏凌霄  阅读(188)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示