zoukankan      html  css  js  c++  java
  • Qt stylesheet

    QPushButton{  

      border-radius:6px; //用来设定边框的弧度。可以设定圆角的按钮

      border:none;         //设置无边界

      font: bold;             //是否显示粗体

      font-family: 微软雅黑; //设置字体所属家族

      font-size: 13px;          //设置字体大小

      font-weight: 20px;   //设定字体深浅

      selection-color: rgb(241, 70, 62);  //设定选中时的颜色

      color: rgb(255, 255, 255);      //设置前景颜色  此为白色

      background: transparent;        //设置背景为透明

      background-position: center;      //用来设定图片的位置, 是左( left )还是( right ), 还是在中间( center ), 是上( top )还是底部 

    }

    #closeBtn{

      background-image: url(:/image/close.png); //添加资源图片

      border-image: url(:/image/close.png); //添加资源图片

      border-style: flat; //设置按钮扁平化效果

    }

      当设置button的icon时, 发现icon的形状并不与button一致。

      设置stylesheet---> border-style: flat;  //这就是设置按钮扁平化效果

    #closeBtn:hover{    //设置放置鼠标显示的资源图片

      background-image: url(:/image/closeHovered.png); 

    }

    #closeBtn:checked{ //设置鼠标按下显示的图片

      background-image: url(:/image/closeHovered.png); 

    }

      注: background-image 和 border-image区别?

        前者是按照像素显示图片, 后者是根据窗体大小来自动缩放图片。

    QTextEdit, QListView{

      background-color: white;

      background-attachment: scroll;

    }

    Btn= new QPushButton(tr("打开文件"), this);

    Btn->setStyleSheet(

      "QPushButton{background-position:left;//设置图片位于左边
      background-color: rgb(33, 33, 33);   //设置背景颜色
      border-top-left-radius:2px;
      background-repeat:no_repeat;      //设置图片不重复
      text-align:right;             //设置字体位于右边
      color:white;               //设置字体为白色
      font-size:15px;            //设置字体大小
      font-family: 微软雅黑;

      border-radius:4px;          //设置按钮弧度
      background-image: url(:/res/openFile.png);}"

      "QPushButton:hover{background-color: rgb(0, 41, 88);
      background-image: url(:/res/openFile_hover.png);}"

      );

    效果图如下:

        

     
  • 相关阅读:
    could not load file or assembly "System.Web.Mvc...
    .Net利用cwbx.dll call AS400 program得到数据
    fastadmin 如何构建组合题--Cannot read property '0' of undefined
    fastadmin的前端js文件中api和event的区别,formatter的意思
    fastadmin是如何使用art-template的,以及如何在js模板中,嵌套JS模板
    学习fastadmin的新技巧:去git里面看文件的修改
    thinphp5,模型调用模型,和控制器调用模型的区别
    fa使用技巧+tp5技巧总结
    input autocomplete的作用是什么?
    fastadmin 实现标签的多选研究---基于fa的test案例,已经CMS中的标签写法
  • 原文地址:https://www.cnblogs.com/jiangson/p/6024566.html
Copyright © 2011-2022 走看看