当前位置:网站首页>QPushButton 样式使用示例(以及按钮setmenu添加下拉菜单的方法)
QPushButton 样式使用示例(以及按钮setmenu添加下拉菜单的方法)
2022-06-26 17:08:00 【Licht小粉】
QPushButton {
font-family: "Microsoft YaHei";
font-size: 16px;
color: #BDC8E2;
font-style: italic;
font-weight: bold;
text-align: left center;
padding-left: 25px;
padding-top: 0px;
border-style: solid;
border-width: 2px;
border-color: aqua;
border-radius: 20px;
background-color: #2E3648;
background-image: url("./image.png");
background-repeat: no-repeat;
background-position: left center;
}
QPuahButton 进行动态样式设置
鼠标悬浮时的样式
QPushButton:hover{
color: red;
border-color: green;
background-color: aqua;
}
鼠标点击时的样式
QPushButton:pressed{
color: green;
border-color: blueviolet;
background-color: black;
}
按钮禁止时的样式
QPushButton:disabled{
color: blue;
border-color: brown;
background-color: aqua;
}
结合使用示例:
const QString NORMAL = {"QPushButton{background-color:lightgray;color:black;text-align:mid;}"
"QPushButton:pressed{ background-color:lightgreen;color:black;text-align:mid; }"};
button->setSheetSytle(NORMAL);对于 QPushButton,可以给它设置添加一个下拉菜单,这需要调用 QPushButton 的 setMenu() 方法,当菜单设置成功后,QPushButton 就会默认添加一个 menu-indicator 下拉菜单指示器图标,我们可以对这个菜单图标进行样式修改
QPushButton::menu-indicator {
image: url(myindicator.png);
subcontrol-position: right center;
subcontrol-origin: padding;
right: 10px;
top: 15px;
}
image 为设置菜单指示器图标
subcontrol-position 为设置菜单指示器图标的位置,如果不设置的话会默认放在右下角处
subcontrol-origin 为设置菜单指示器图标与按钮之间的停靠位置,默认为 padding
right top left bottom 为设置菜单指示器图标距离按钮四个位置的距离
QPushButton::menu-indicator:hover {
image: url(./image1.png)
}
QPushButton::menu-indicator:pressed{
image: url(./image2.png)
}
QPushButton::menu-indicator:open{
image: url(./image2.png)
}
边栏推荐
- Basic requirements: 7 problems in singleton mode
- Platform management background and merchant menu resource management: merchant registration management design
- Teach you to learn dapr - 2 Must know concept
- Quantitative contract system development analysis case - detailed explanation of contract quantitative system development scheme
- Getting started with mongodb
- Inspirational. In one year, from Xiaobai to entering the core Department of Alibaba, his counter attack
- Live broadcast preview | how can programmers improve R & D efficiency? On the evening of June 21, the video number and station B will broadcast live at the same time. See you or leave!
- MySQL exports all table indexes in the database
- 背包问题求方案数
- Redis and database data consistency
猜你喜欢

去中心化NFT交易协议将击败OpenSea
![[suggested collection] 11 online communities suitable for programmers](/img/6b/d5c68e93384fd314d0cb27d9df1cb9.jpg)
[suggested collection] 11 online communities suitable for programmers

Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC

Introduction to distributed cache / cache cluster

Necessary decorator mode for 3 years' work

Microservice architecture practice: business management background and SSO design: SSO design

Web3 decentralized storage ecological landscape

Over the weekend: 20000 words! Summary of JVM core knowledge, 18 serial cannons as a gift

Today, I met a "migrant worker" who took out 38K from Tencent, which let me see the ceiling of the foundation

Kubernetes essential tools: 2021
随机推荐
Kubernetes essential tools: 2021
Find all primes less than or equal to Lim, store them in AA array, and return the number of primes
Discover K8E: minimalist kubernetes distribution
【推荐系统学习】推荐系统架构
LeetCode——226. 翻轉二叉樹(BFS)
The student record consists of student number and academic performance. The data of n students have been stored in the a structure array to find out the student record with the lowest performance
Basic requirements: 7 problems in singleton mode
Teach you to learn dapr - 1 The era of net developers
探讨:下一代稳定币
sql中ROUND和TRUNCATE的区别(四舍五入还是截取小数点后几位)
玩转Linux,轻松安装配置MySQL
In those years, interview the abused red and black trees
Count the number of each vowel letter in the string
Microservice architecture practice: business management background and SSO design, SSO client design
Daily record 2
Leetcode - 226. Retourner l'arbre binaire (bfs)
Platform management background and merchant menu resource management: merchant registration management design
Leetcode 1169. Query invalid transactions (if the amount of data is small, this problem still needs to be solved by violent enumeration)
Play with Linux and easily install and configure MySQL
Use FST JSON to automatically generate faster JSON serialization methods