QT界面技巧-QComboBox的QSS设置

#QT界面技巧-QComboBox的QSS设置

如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

环境:
QT版本:5.6.2
操作系统:windows 7 64bit

##1.QComboBox设置下拉框item高度

/*global QComboBox height*/
QComboBox QAbstractItemView::item {
    height: 50px;
}

注意:在QSS中设置完后,需要调用如下代码,否则会使用默认的item样式,导致设置无效

    //if no this code, the style sheet wont be applied to the default combobox item view.
    ui->comboBox->setView(new  QListView());

默认样式:
这里写图片描述
修改后样式:
这里写图片描述

##2.QComboBox设置下拉框item的字体大小

/*global QComboBox font size*/
QComboBox QAbstractItemView{
    font-size: 18px;
}

注意:在QSS中设置完后,需要调用如下代码,否则会使用默认的item样式,导致设置无效

    //if no this code, the style sheet wont be applied to the default combobox item view.
    ui->comboBox->setView(new  QListView());

默认样式:
这里写图片描述
修改后样式:
这里写图片描述


觉得文章对你有帮助,可以扫描二维码捐赠给博主,谢谢!
在这里插入图片描述
如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

itas109

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值