Pseudo elements in qt designer
P粉600402085
P粉600402085 2024-01-10 17:44:05
0
1
475

I want to use a pseudo element to create a vertical line for the button on the left and dim it on hover, but qt-designer styleSheet doesn't understand me and it doesn't display correctly, here is my code:

QPushButton{
position: relative;
padding: 10px 20px;
border: none;
background-color: #fff;
color: #333;
cursor: pointer;
overflow: hidden;
}

QPushButton:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 5px;
height: 100%;
background-color: #C6C6C6;
opacity: 0.5;
transition: all 0.3s ease-in-out;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}

QPushButton:hover:before {
background-color: #7F7F7F;
opacity: 0.8;
}

How does it look? Enter image description here as i wish Enter image description here

I tried rewriting it in a different way but I'm not very good at it

P粉600402085
P粉600402085

reply all(1)
P粉676588738

Qt does not support CSS 3.0, but supports CSS 2.0. You need to modify your CSS to get what you want. The specific methods are as follows:

QPushButton{
position: relative;
padding: 10px 20px;
border: none;
background-color: #fff;
color: #333;
cursor: pointer;
overflow: hidden;
}

QPushButton:hover {
width: 5px;
height: 100%;
border-left: 6px solid #7F7F7F;
opacity: 0.5;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;

opacity: 0.8;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template