当前位置:网站首页>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)
}
边栏推荐
- num[i]++
- [recommendation system learning] recommendation system architecture
- Over the weekend: 20000 words! Summary of JVM core knowledge, 18 serial cannons as a gift
- 直播预告|程序员进击,如何提升研发效能?6月21日晚视频号、B站同步直播,不见不散!
- Multiply the values of the upper triangular elements of the array by M
- Notes on flowus
- Leetcode daily [2022 - 02 - 16]
- SIGIR 2022 | University of Hong Kong and others proposed the application of hypergraph comparative learning in Recommendation System
- 玩轉Linux,輕松安裝配置MySQL
- 【动态规划】剑指 Offer II 091. 粉刷房子
猜你喜欢

【代码随想录-动态规划】T583、两个字符串的删除操作

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

Platform management background and merchant menu resource management: Design of platform management background data service

MySQL add column failed because there was data before, not null by default
![[recommendation system learning] technology stack of recommendation system](/img/ff/afc6f4b0997cfcb9e01ffbebf2a872.png)
[recommendation system learning] technology stack of recommendation system

ACL 2022 | 基于神经标签搜索的零样本多语言抽取式文本摘要

Incomplete line spacing adjustment of formula display in word

Byte interview: two array interview questions, please accept

Which low code platform is more friendly to Xiaobai? Here comes the professional evaluation!

Platform management background and merchant menu resource management: access control design of platform management background
随机推荐
Programmer interview guide - self introduction
Leetcode topic [array] -268- missing numbers
Teach you to learn dapr - 5 Status management
量化合约系统开发分析案例丨合约量化系统开发方案详解
Daily record 2
Environment setup mongodb
宝藏又小众的CTA动画素材素材网站分享
Necessary decorator mode for 3 years' work
背包问题求方案数
对NFT市场前景的7个看法
Basic requirements: 7 problems in singleton mode
Cloud native 02: Alibaba cloud cloud efficient flow pipeline
Leetcode daily [2022 - 02 - 16]
并发之线程安全
Microservice architecture practice: user login and account switching design, order query design of the mall
防火 疏散 自救…这场安全生产暨消防培训干货满满!
[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
num[i]++
[Error] ld returned 1 exit status
Leetcode topic [array] -283- move zero