关于QT setStyleSheet的一些格式说明


下面的内容都是我从网上自己总结的:

 

1  btn1=new QPushButton(this);
   btn1->setStyleSheet("QPushButton{color:red;background:yellow}"); //设定前景颜色,就是字体颜色
   // btn1->setStyleSheet("QPushButton{background:yellow}");

2  btn2=new QPushButton(this);
btn2->setStyleSheet("QPushButton{color:red;background-color:rgb(200,155,100)}");//使用rgb来设定背景颜色
 
3  btn3=new QPushButton(this);
   btn3->setStyleSheet("QPushButton{background-image:url(image/1.png);background-repeat: repeat-xy;background-position: center;
   background-attachment: fixed;background-clip: padding}");
  
   btn4=new QPushButton(this);
   btn4->setStyleSheet("QPushButton{border: 3px solid red;border-radius:8px}"); //设定边框宽度以及颜色

其中:
  
//border-image用来设定边框的背景图片。
//background-repeat可以设定背景图片的重复规则,这里设定仅在xy方向都重复,所以图片会被重复一次
//background-position用来设定图片的位置,是左(left)还是右(right),还是在中间(center),是上(top)还是底部(bottom)
//background-attachment用来这定背景图片是否卷动或者和窗口大小相匹配,默认是卷动的
//border-radius用来设定边框的弧度。可以设定圆角的按钮
 下面是效果图:

 
 
 
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM