时间: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号