开发者

Italic QComboBox button text

开发者 https://www.devze.com 2023-01-30 10:55 出处:网络
I have a read-only QComboBox where I want the text in the \"button\" part (i.e. not the drop down list that can appear) to be italic. I tried using

I have a read-only QComboBox where I want the text in the "button" part (i.e. not the drop down list that can appear) to be italic. I tried using

combo.setStylesheet('font-style: italic')

but this also makes the text in the drop-down list italic. How can I force the stylesheet to not开发者_Python百科 apply to the drop down list? I know I can access the drop-down part by QComboBox::view() but how can I then reset the stylesheet of that part?

Is there any other way to make only the text in the button part of a QComboBox italic?


You can try something like this

MyComboBox::showPopup()
{
    QStyle widget_style = style();
    setStyle(QApplication::style());
    QComboBox::showPopup();
    setStyle(widget_style);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号