zoukankan      html  css  js  c++  java
  • qt--mask蒙版

        this->resize(500,300);
        QLabel* label=new QLabel("标签",this);
        label->move(10,10);
        QLabel* label1=new QLabel("标签",this);
        label1->move(250,10);
        QPixmap p("./a.png");
        label->setPixmap(p);
        label->resize(p.size());
    
        //QPixmap m("./m.png");  //载入蒙版图片--方法一
        //注意:不想显示的部分必须ps成透明
    
        QBitmap m("./mb.png");  //载入蒙版图片--方法二
        //注意:不想显示的部分必须ps成白色,想显示的部分ps成黑色
    
        label1->setPixmap(m);
        //label->setMask(m.mask()); //设置蒙版--对应方法一
        label->setMask(m);  //设置蒙版--对应方法二

    上面工程下载: 链接:https://pan.baidu.com/s/1fCoMOwF-kcsSAL6b2_SElA    提取码:6666    

    蒙版实例--不规则按钮

        this->resize(400,300);
        QPushButton* button=new QPushButton("按钮",this);
        QPixmap p("./a.png");
        button->move(10,10);
        button->resize(p.size());
        //button->setStyleSheet("background-image:url(./a.png);");
        button->setStyleSheet("QPushButton{background:url(./a.png);border:0px;}"  //按钮的三种状态
            "QPushButton:hover{background:url(./b.png);border:0px}"
            "QPushButton:pressed{background:url(./c.png); position: relative;top: 1px; left: 1px;}");
        QBitmap m("./m.png");
    
        button->setMask(m);

    效果图:

     工程下载:链接:https://pan.baidu.com/s/1LQlJXXsMWxdpz45xkZEqsw   提取码:6666   

     

  • 相关阅读:
    electron项目打包成dmg
    到底什么是流?
    cent日常操作实践(二)
    pm2基本使用
    koa + sequelize + mysql 项目实践笔记
    cenos 磁盘操作
    MySQL基础操作汇总二
    Python调用shell
    Python常用模块之七 PIL
    random
  • 原文地址:https://www.cnblogs.com/liming19680104/p/13907376.html
Copyright © 2011-2022 走看看