3 Attachment(s)
QPushButton text truncated by using StyleSheet border-image
Hi,
I met with a problem when i usde Qt Stylesheet's border-image property. I got my pushButton's text truncated.
Code:
pushBtn->setText("Entrexe regVunsorg"); // For testing
pushBtn->setStyleSheet(
"color : #f5f5f5;"
" border-image: url(:/resouces/images/border/border-image.png);"
" margin-top:0px;"
" margin-left:0px;"
" margin-bottom:1px;"
" margin-right:1px;"
" border-left-width: 22px;"
" border-right-width: 22px;"
);
pushBtn->setGeometry(430, 100, 180, 44);
The result of the button is:
Attachment 13334
The border-image is like this:
Attachment 13335
When I tried in chrome by using CSS:
Code:
.button1 {
/* button setting environment */
background: #ffffff;
font-size: 16px;
font-family: ArialUnicode;
white-space: nowrap;
display: flex;
justify-content: center;
text-align: center;
/* example the sample as Qt style sheet */
height: 44px;
width: 180px;
color: #f5f5f5;
border-image: url(D:\\workdir\\test\\border-image.png) 0 22 0 22 stretch stretch;
margin-top: 0px;
margin-left: 0px;
margin-bottom: 1px;
margin-right: 1px;
border-left-width: 22px;
border-right-width: 22px;
}
.button2 {
/* button setting environment */
background: #ffffff;
font-size: 16px;
font-family: ArialUnicode;
white-space: nowrap;
display: flex;
justify-content: center;
text-align: center;
height: 44px;
width: 180px;
color: #f5f5f5;
border-image: url(D:\\workdir\\test\\border-image.png) 0 22 0 22 stretch stretch;
margin-top: 0px;
margin-left: 0px;
margin-bottom: 1px;
margin-right: 1px;
/* border-left-width: 22px; */
/* border-right-width: 22px; */
border-image-slice: 22;
border-image-width: 22px;
}
Html Code:
Code:
<body>
<div class="demo">
<p>Qt Sample</p>
<button class="button1" >Entrexe regVunsorg</button>
<p>Modidied Sample in Chrome</p>
<button class="button2">Entrexe regVunsorg</button>
<button class="button3">Entrexe regVunsorg</button>
</body>
The results are as follows:
Attachment 13338
I wonder whether Qt Stylesheet can achieve the result like the 3rd picture, the second button.
If it works, could someone here tell me how to achieve this?
Many thanks,
Eason