登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沙漠里de烟雨

原创分享,禁止转载

 
 
 

日志

 
 

QML 自定义tab形状  类似梯形  

2017-05-19 17:00:17|  分类: QT5.x与QML |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
import QtQuick 2.0
Rectangle
{
    id: root
    width: 200
    height: 100
    color: "red"
    Canvas
    {
        id: canvas
        anchors.fill: parent
        onPaint:
        {
            var top_gap = 10;
            var top_radius = 10
            var bottom_gap = 15; //==bottom_radius;
            var x0 = 0;
            var y0 = canvas.height;
            var x1 = bottom_gap;
            var y1 = canvas.height;
            var x2 = bottom_gap;
            var y2 = canvas.height-bottom_gap;
            var ctx = getContext('2d');

            ctx.strokeStyle = "black"
            ctx.beginPath();
            ctx.moveTo(x0,y0);
            ctx.arcTo(x1,y1,x2,y2,bottom_gap); x0=bottom_gap; y0=top_gap+top_radius;
            ctx.lineTo(x0,y0); x1=x0; y1=top_gap; x2=x1+top_radius; y2=y1;
            ctx.arcTo(x1,y1,x2,y2,top_radius); x0=canvas.width-bottom_gap-top_radius; y0=y2;
            ctx.lineTo(x0,y0); x1=x0+top_radius; y1=y0; x2=x1; y2=y1+top_radius;
            ctx.arcTo(x1,y1,x2,y2,top_radius); x0=x2; y0=canvas.height-bottom_gap;
            ctx.lineTo(x0,y0); x1=x0; y1=canvas.height; x2=canvas.width; y2=y1;
            ctx.arcTo(x1,y1,x2,y2,bottom_gap);
            ctx.closePath();
            ctx.stroke();
        }
    }

}
QML  自定义tab形状  类似梯形 - 漠雨 - 沙漠里de烟雨__风尘无名
 
  评论这张
 
阅读(550)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018