Qt给控件添加图片

双击qrc文件,选择下面的addFiles,将图片添加进来,然后选中图片右键Select All

设置控件字符:

ui.btnSet->setText("");

设置资源:

ui.btnSet->setStyleSheet("QPushButton{background-image:url(:/QtWidgetsApplication2/resources/set.png)}");

设置无边框:

ui.btnSet->setStyleSheet("QPushButton{background-image:url(:/QtWidgetsApplication2/resources/set.png);border:none}");

点击变色:

ui.btnSet->setStyleSheet("QPushButton{background-image:url(:/QtWidgetsApplication2/resources/set.png);border:none}\
		QPushButton::hover{background-color:rgb(200,200,200)}");

你可能感兴趣的:(qt,vue.js,开发语言)