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);
}