首页 > 科技热点 > 正文内容

qt如何给控件设置图标

时间:2024-10-19 21:02:16

qt控件设置图标方法总结

1.窗口设置图标。this -> setWindowIcon ( QIcon ( ":/rabbit.ico" ) ) ;

2.qtreewidget设置图标。QTreeWidgetItem * topitem1 = new QTreeWidgetItem ( ui -> treeWidget ) ; topitem1 -> setText ( 0 , QString ( "用户管理" ) ) ; QIcon icon1 ; icon1 . addPixmap ( QPixmap ( ":/customer.png" ) ) ; topitem1 -> setIcon ( 0 , icon1 ) ; ui -> treeWidget -> addTopLevelItem ( topitem1 ) ;

3.qpushbutton设置图标。QIcon icon1 ; icon1 . addPixmap ( QPixmap ( ":/add-circle" ) ) ; ui -> pushButton -> setIcon ( icon1 ) ;

4.qcheckbox替换图片。QCheckBox::indicator { width : 40px ; height : 40px ; } QCheckBox::indicator:unchecked { border-image : url ( :/mark.png ) ; } QCheckBox::indicator:checked { border-image : url ( :/mark-fill.png ) ;

版权声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益, 请作者持权属证明与本网联系,我们将及时更正、删除,谢谢您的支持与理解。
标签:科技热点

科技之家 广州小漏斗信息技术有限公司 版权所有 提供支持 粤ICP备20006251号