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

你可能感兴趣的:(学习笔记,qss,qt)