当前位置:网站首页>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)
}
边栏推荐
- 物联网协议的王者:MQTT
- Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC
- The texstudio official website cannot be opened
- Redis and database data consistency
- Demonstrate to Xiaobai the case of sub database and sub table
- Multiply the values of the upper triangular elements of the array by M
- Teach you to learn dapr - 5 Status management
- Platform management background and merchant menu resource management: access control design of platform management background
- Play with Linux and easily install and configure MySQL
- Call the random function to generate 20 different integers and put them in the index group of institute a
猜你喜欢

20: Chapter 3: develop the pass service: 3: get through the redis server in the program; (it only connects with the redis server and does not involve specific business development)

背包问题求方案数

Notes on flowus

Synchronized description of concurrency

Leetcode HOT100 (22--- bracket generation)

Necessary decorator mode for 3 years' work
![[suggested collection] 11 online communities suitable for programmers](/img/6b/d5c68e93384fd314d0cb27d9df1cb9.jpg)
[suggested collection] 11 online communities suitable for programmers

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

物联网协议的王者:MQTT

Here comes the hero League full skin Downloader
随机推荐
Getting started with mongodb
Synchronized description of concurrency
Daily record 2
Treasure and niche CTA animation material website sharing
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
[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
Microservice architecture practice: business management background and SSO design: SSO design
背包问题求方案数
Teach you to learn dapr - 9 Observability
分布式缓存/缓存集群简介
Leetcode daily [2022 - 02 - 16]
丰富专业化产品线, 江铃福特领睿·极境版上市
Secrets of gear contract
MySQL add column failed because there was data before, not null by default
Implementation of MySQL master-slave architecture
[latex bearer] use tables in \title (error \begin doesn't match its definition.)
Calculate the average of N numbers in the group indexed by the formal parameter x, move the data less than the average in the group indexed to the front of the array, and move the data greater than or
[qt learning notes]qt inter thread data communication and data sharing
Sandboxed container: container or virtual machine
关于FlowUs这一款国民好笔记