• Qt 通过绘画设置边框阴影


    [cpp] view plain copy
     
    1. 首先widget设置  
    2.     setWindowFlags(Qt::FramelessWindowHint);  
    3.     setAttribute(Qt::WA_TranslucentBackground, true);  

    [cpp] view plain copy
     
    1. 然后重载paintevent  
    2. void ShadowMethod::paintEvent(QPaintEvent *event)  
    3. {  
    4.     QPainterPath path;  
    5.      path.setFillRule(Qt::WindingFill);  
    6.      path.addRect(10, 10, this->width()-20, this->height()-20);  
    7.   
    8.      QPainter painter(this);  
    9.      painter.setRenderHint(QPainter::Antialiasing, true);  
    10.      painter.fillPath(path, QBrush(Qt::white));  
    11.   
    12.      QColor color(92,93,95,50);  
    13.      int arr[10] = {150,120,80,50,40,30,20,10,5,5};  
    14.      for(int i=0; i<10; i++)  
    15.      {  
    16.          QPainterPath path;  
    17.          path.setFillRule(Qt::WindingFill);  
    18.          if(i == 5)  
    19.              path.addRect(10-i-1, 10-i-1, this->width()-(10-i)*2, this->height()-(10-i)*2);  
    20.          else  
    21.             path.addRoundedRect(10-i-1, 10-i-1, this->width()-(10-i)*2, this->height()-(10-i)*2,2,2);  
    22.   
    23.          color.setAlpha(arr[i]);  
    24.          painter.setPen(color);  
    25.          painter.drawPath(path);  
    26.   
    27.      }  
    28.   
    29.   
    30. }  
    [cpp] view plain copy
     
    1.   
    [cpp] view plain copy
     
    1. 效果图:  
    [cpp] view plain copy
     
    1. <img src="http://img.blog.csdn.net/20171011165958714?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveHpwYmxvZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">  
     
    https://blog.csdn.net/xzpblog/article/details/78205710
  • 相关阅读:
    python爬虫
    绕过CDN查找网站真实IP方法收集
    拖库
    伪静态注入的总结
    国外安全网站信息收集
    python字典去重脚本
    AOP 的利器:ASM 3.0 介绍
    JDK工具
    JVM性能调优监控工具
    DMZ
  • 原文地址:https://www.cnblogs.com/findumars/p/8627697.html
Copyright © 2020-2023  润新知