当前位置:网站首页>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)
}
边栏推荐
- Programmer interview guide - self introduction
- 【代码随想录-动态规划】T583、两个字符串的删除操作
- 玩轉Linux,輕松安裝配置MySQL
- 20:第三章:开发通行证服务:3:在程序中,打通redis服务器;(仅仅是打通redis服务器,不涉及具体的业务开发)
- Redis overview
- The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
- 对NFT市场前景的7个看法
- Redis OM . Net redis object mapping framework
- Discover K8E: minimalist kubernetes distribution
- Wechat app mall, review products, upload commodity pictures, and score Commodity Services
猜你喜欢

Teach you to learn dapr - 8 binding

【万字总结】以终为始,详细分析高考志愿该怎么填

Turtle cartography
![[suggested collection] 11 online communities suitable for programmers](/img/6b/d5c68e93384fd314d0cb27d9df1cb9.jpg)
[suggested collection] 11 online communities suitable for programmers

Leetcode 1170. Frequency of occurrence of the minimum letter of the comparison string (yes, solved)

Cache breakdown! Don't even know how to write code???

When I was in the library, I thought of the yuan sharing mode

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

探讨:下一代稳定币

Basic requirements: 7 problems in singleton mode
随机推荐
Sandboxed container: container or virtual machine
Redis and database data consistency
[recommendation system learning] recommendation system architecture
Play with Linux and easily install and configure MySQL
[suggested collection] 11 online communities suitable for programmers
Teach you to learn dapr - 4 Service invocation
Leetcode - 226. Retourner l'arbre binaire (bfs)
Find out the maximum value of each column element of NxN matrix and store it in the one-dimensional array indicated by formal parameter B in order
20:第三章:开发通行证服务:3:在程序中,打通redis服务器;(仅仅是打通redis服务器,不涉及具体的业务开发)
Classical synchronization problem
[buuctf.reverse] 126-130
sparksql如何通过日期返回具体周几-dayofweek函数
10 cloud security best practices that enterprises need to know
Incomplete line spacing adjustment of formula display in word
MySQL add column failed because there was data before, not null by default
经典同步问题
关于FlowUs这一款国民好笔记
LeetCode——226. 翻转二叉树(BFS)
去中心化NFT交易协议将击败OpenSea
[matlab project practice] prediction of remaining service life of lithium ion battery based on convolutional neural network and bidirectional long short time (cnn-lstm) fusion