直接上代码,使用样式的方式:
ui.btFilm->setStyleSheet("QToolButton{border-image:url(:/test/film.png) 0 0 80 0 0;border-style:flat;background-attachment:fixed;}"
"QToolButton:hover:pressed{border-image:url(:/test/film.png) 80 0 0 0 0;border-style:flat;background-attachment:fixed;}"
"QToolButton:hover:!pressed{border-image:url(:/test/film.png) 40 0 40 0 0;border-style:flat;background-attachment:fixed;}"
"QToolButton:focus{border-image:url(:/test/film.png) 40 0 40 0 0;border-style:flat;background-attachment:fixed;}");