开发者

Italic QComboBox button text

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜